#35169 [NEW]: proc_get_status lost exitcode after second call
| From: | c dot affolter at stepping-stone dot ch | Date: | Wed, 09 Nov 2005 10:18:52 +0000 |
| Subject: | #35169 [NEW]: proc_get_status lost exitcode after second call | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-87920@lists.php.net to get a copy of this message | ||
From: c dot affolter at stepping-stone dot ch
Operating system: Linux version 2.4.21
PHP version: 5.1.0RC4
PHP Bug Type: Program Execution
Bug description: proc_get_status lost exitcode after second call
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 bug report at http://bugs.php.net/?id=35169&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35169&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35169&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35169&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=35169&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35169&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35169&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35169&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35169&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35169&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35169&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=35169&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=35169&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35169&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35169&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35169&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35169&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35169&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35169&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35169&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35169&r=mysqlcfg