PHP :: Bug #39322 :: proc_terminate(): loosing process resource
| Bug #39322 | proc_terminate(): loosing process resource | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2006-10-31 16:22 UTC | Modified: | 2007-02-14 19:22 UTC |
|
||||||||||
| From: | c dot affolter at stepping-stone dot ch | Assigned: | ||||||||||||
| Status: | Closed | Package: | Program Execution | |||||||||||
| PHP Version: | * | OS: | * | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2006-10-31 16:22 UTC] c dot affolter at stepping-stone dot ch
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 ...
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2007-01-23 22:18 UTC] viraptor+phpbug at gmail dot com
[2007-01-23 22:26 UTC] nlopess@php.net
[2007-02-14 19:22 UTC] nlopess@php.net
[2011-09-07 18:09 UTC] rasmus@php.net