From:             c dot affolter at stepping-stone dot ch
Operating system: Linux 2.4
PHP version:      5.1.6
PHP Bug Type:     Program Execution
Bug description:  proc_terminate(): loosing process resource 

Description:
------------
After sending a signal via proc_terminate() to a process, the process
resource gets closed immediately.
This means that calling proc_get_status() afterwards, will throw a warning
about an invalid process resource.

This behaviour is somewhat cumbersomely, since you're unable to check if
it was your signal which has caused the process to terminate or if the
process has stopped.

Is this a bug or an undocumented behaviour?

BTW:
Sending a signal via the shell or through posix_kill(), will retain the
status for the first proc_get_status() call. 

Reproduce code:
---------------
<?php
$descriptors = array(
    0 => array('pipe', 'r'),
    1 => array('pipe', 'w'),
    2 => array('pipe', 'w'));

$pipes = array();

$process = proc_open('/bin/sleep 120', $descriptors, $pipes);

proc_terminate($process);
var_dump(proc_get_status($process));

?>



Expected result:
----------------
array(8) {
  ["command"]=>
  string(14) "/bin/sleep 120"
  ["pid"]=>
  int(23011)
  ["running"]=>
  bool(false)
  ["signaled"]=>
  bool(true)
  ["stopped"]=>
  bool(false)
  ["exitcode"]=>
  int(-1)
  ["termsig"]=>
  int(15)
  ["stopsig"]=>
  int(0)
}

Actual result:
--------------
Warning: proc_get_status(): 7 is not a valid process resource in ...

-- 
Edit bug report at http://bugs.php.net/?id=39322&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39322&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39322&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39322&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39322&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39322&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39322&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39322&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39322&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39322&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39322&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39322&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39322&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39322&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39322&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39322&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39322&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39322&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39322&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39322&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39322&r=mysqlcfg

Reply via email to