|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32210 proc_get_status "running"-field true after execution of command
Submitted: 2005-03-07 00:46 UTC Modified: 2005-03-07 17:19 UTC
From: joh at deworks dot net Assigned: wez (profile)
Status: Closed Package: Program Execution
PHP Version: 5CVS-2005-03-07 (dev) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
42 - 33 = ?
Subscribe to this entry?

 [2005-03-07 00:46 UTC] joh at deworks dot net
The "running" field of the status array returned by proc_get_status() is always TRUE after the execution of the command is finished. As the manual says, running should be "TRUE if the process is still running, FALSE if it has terminated". What is strange is that at some point of the command execution, it's false. Maybe it's value is the opposite of what the manual says?

Reproduce code:
(Best run from the command line)

$handle = proc_open("ls", array(2 => array("pipe", "r")), $pipes);

while (true) {
	$status = proc_get_status($handle); 				var_dump($status["running"]);

Expected result:
<output of the command>

Actual result:
<output of the command>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-07 02:06 UTC]
It really looks that proc_get_status() doesn't take into account the result of waitpid() and still returns TRUE even when child process is already dead.

Wez, take a look at the patch, plz.

Index: proc_open.c
RCS file: /repository/php-src/ext/standard/proc_open.c,v
retrieving revision 1.31
diff -u -p -d -r1.31 proc_open.c
--- proc_open.c 21 Feb 2005 09:50:48 -0000      1.31
+++ proc_open.c 7 Mar 2005 01:04:08 -0000
@@ -414,6 +414,10 @@ PHP_FUNCTION(proc_get_status)
                        stopsig = WSTOPSIG(wstatus);
+       else if (wait_pid == -1) {
+               /* -1 means such child doesn't exist i.e. it already exited */
+               running = 0;
+       }

        add_assoc_bool(return_value, "running", running); 
 [2005-03-07 17:19 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 13:01:30 2024 UTC