ID: 32210 Updated by: [EMAIL PROTECTED] Reported By: joh at deworks dot net -Status: Assigned +Status: Closed Bug Type: Program Execution Operating System: Linux PHP Version: 5CVS-2005-03-07 (dev) Assigned To: wez New Comment:
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 http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2005-03-07 02:06:51] [EMAIL PROTECTED] 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; + } #endif add_assoc_bool(return_value, "running", running); ------------------------------------------------------------------------ [2005-03-07 00:46:29] joh at deworks dot net Description: ------------ 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"]); sleep(1); } Expected result: ---------------- bool(false) <output of the command> bool(true) bool(false) bool(false) ... Actual result: -------------- bool(true) <output of the command> bool(false) bool(true) bool(true) ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32210&edit=1