|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-11-09 12:53 UTC] sniper@php.net
[2005-11-10 19:52 UTC] iliaa@php.net
[2005-11-29 15:57 UTC] vrana@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 06:00:01 2025 UTC |
Description: ------------ After a process (via proc_open()) has exited, proc_get_status() returns the actual exit code (within array['exitcode']) of that process. If proc_get_status() gets called a second time, the previous exit code will be lost (-1), because the internal waitpid() function won't return the pid a second time. So, either this is a bug and proc_get_status() has to keep track of the exitcode value (as it does for 'command', 'pid' and 'running') or this behaviour should be mentioned in the documentation. Reproduce code: --------------- #!/usr/bin/env php <?php $descriptors = array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); $pipes = array(); $ressource = proc_open('/bin/true', $descriptors, $pipes); echo stream_get_contents($pipes[1]); // first call exitcode == 0 var_dump(proc_get_status($ressource)); // second call exitcode == -1 var_dump(proc_get_status($ressource)); fclose($pipes[1]); proc_close($ressource); ?> Expected result: ---------------- array(8) { ["command"]=> string(9) "/bin/true" ["pid"]=> int(31590) ["running"]=> bool(false) ["signaled"]=> bool(false) ["stopped"]=> bool(false) ["exitcode"]=> int(0) ["termsig"]=> int(0) ["stopsig"]=> int(0) } array(8) { ["command"]=> string(9) "/bin/true" ["pid"]=> int(31590) ["running"]=> bool(false) ["signaled"]=> bool(false) ["stopped"]=> bool(false) ["exitcode"]=> int(0) ["termsig"]=> int(0) ["stopsig"]=> int(0) } Actual result: -------------- array(8) { ["command"]=> string(9) "/bin/true" ["pid"]=> int(31590) ["running"]=> bool(false) ["signaled"]=> bool(false) ["stopped"]=> bool(false) ["exitcode"]=> int(0) ["termsig"]=> int(0) ["stopsig"]=> int(0) } array(8) { ["command"]=> string(9) "/bin/true" ["pid"]=> int(31590) ["running"]=> bool(false) ["signaled"]=> bool(false) ["stopped"]=> bool(false) ["exitcode"]=> int(-1) ["termsig"]=> int(0) ["stopsig"]=> int(0) }