Edit report at https://bugs.php.net/bug.php?id=64465&edit=1
ID: 64465
User updated by: andrey dot kalinovsky at gmail dot com
Reported by: andrey dot kalinovsky at gmail dot com
Summary: proc_get_status update time when using
proc_terminate
Status: Not a bug
Type: Bug
Package: Program Execution
Operating System: OSX, Ubuntu
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thank you for your input. But pcntl_waitpid is blocking, so I cannot use it.
Are
there any other ways by any chance ?
Previous Comments:
------------------------------------------------------------------------
[2013-03-20 19:16:37] [email protected]
proc_terminate() is documented as being asynchronous in the manual â all it
really does internally is to call kill(), which simply sends a signal.
pcntl_waitpid() is presumably what you need to call after proc_terminate(), if
you don't want to poll with proc_get_status().
------------------------------------------------------------------------
[2013-03-20 15:56:39] andrey dot kalinovsky at gmail dot com
This is a big issue when working with libev eventloop, since it's about
handling
child processes asynchronously. So, I can't just let the sleep(1) here, the
solution must be asynchronous...
------------------------------------------------------------------------
[2013-03-20 15:32:26] andrey dot kalinovsky at gmail dot com
Description:
------------
After proc_terminate has been called, there is a time during which
proc_get_status
will still describe the child process as running.
Test script:
---------------
<?php
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
$process = proc_open("sleep 20", $descriptorspec, $pipes);
var_dump(proc_get_status($process));
proc_terminate($process);
var_dump(proc_get_status($process));
sleep(1);
var_dump(proc_get_status($process));
Expected result:
----------------
array(8) {
'command' =>
string(8) "sleep 20"
'pid' =>
int(14027)
'running' =>
bool(true)
'signaled' =>
bool(false)
'stopped' =>
bool(false)
'exitcode' =>
int(-1)
'termsig' =>
int(0)
'stopsig' =>
int(0)
}
array(8) {
'command' =>
string(8) "sleep 20"
'pid' =>
int(14027)
'running' =>
bool(false)
'signaled' =>
bool(true)
'stopped' =>
bool(false)
'exitcode' =>
int(-1)
'termsig' =>
int(15)
'stopsig' =>
int(0)
}
array(8) {
'command' =>
string(8) "sleep 20"
'pid' =>
int(14027)
'running' =>
bool(false)
'signaled' =>
bool(true)
'stopped' =>
bool(false)
'exitcode' =>
int(-1)
'termsig' =>
int(15)
'stopsig' =>
int(0)
}
Actual result:
--------------
array(8) {
'command' =>
string(8) "sleep 20"
'pid' =>
int(14027)
'running' =>
bool(true)
'signaled' =>
bool(false)
'stopped' =>
bool(false)
'exitcode' =>
int(-1)
'termsig' =>
int(0)
'stopsig' =>
int(0)
}
array(8) {
'command' =>
string(8) "sleep 20"
'pid' =>
int(14027)
'running' =>
bool(true)
'signaled' =>
bool(false)
'stopped' =>
bool(false)
'exitcode' =>
int(-1)
'termsig' =>
int(0)
'stopsig' =>
int(0)
}
array(8) {
'command' =>
string(8) "sleep 20"
'pid' =>
int(14027)
'running' =>
bool(false)
'signaled' =>
bool(true)
'stopped' =>
bool(false)
'exitcode' =>
int(-1)
'termsig' =>
int(15)
'stopsig' =>
int(0)
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64465&edit=1