ID: 35169 Updated by: [EMAIL PROTECTED] Reported By: c dot affolter at stepping-stone dot ch -Status: Assigned +Status: Closed Bug Type: Documentation problem Operating System: Linux version 2.4.21 PHP Version: 5.1.0RC4 Assigned To: wez New Comment:
This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Only first call of this function return real value, next calls return -1. Previous Comments: ------------------------------------------------------------------------ [2005-11-10 19:52:22] [EMAIL PROTECTED] This is a not a bug, but an undocumented behaviour. ------------------------------------------------------------------------ [2005-11-09 12:53:39] [EMAIL PROTECTED] Wez, how is it? Bug or undocumented behaviour? ------------------------------------------------------------------------ [2005-11-09 11:18:51] c dot affolter at stepping-stone dot ch 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) } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35169&edit=1