|  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
Status: Closed Package: Program Execution
PHP Version: 5CVS-2005-03-07 (dev) OS: Linux
Private report: No CVE-ID:
 [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-2015 The PHP Group
All rights reserved.
Last updated: Wed Dec 02 03:01:32 2015 UTC