ID:               35169
 Updated by:       [EMAIL PROTECTED]
 Reported By:      c dot affolter at stepping-stone dot ch
-Status:           Open
+Status:           Assigned
 Bug Type:         Program Execution
 Operating System: Linux version 2.4.21
 PHP Version:      5.1.0RC4
-Assigned To:      
+Assigned To:      wez
 New Comment:

Wez, how is it? Bug or undocumented behaviour?


Previous Comments:
------------------------------------------------------------------------

[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

Reply via email to