嘿,我最近一直在使用 proc_open,它从不等它完成后再继续。确保指定管道,而不仅仅是使用空 array()
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
);
并将 proc_open 分配给一个变量。
$myProc = proc_open("/var/www/other_scripts/perl/apps/emails_extract_from_url.pl \"$stoopid\"", $descriptorspec , $foo)
然后,您可以使用proc_get_status($myProc);
更多信息在这里http://au.php.net/proc_open
有关关闭的更多信息。
$temp = fgets($this->open_pipes[$thread_id][1], 1024);
if($this->checkFinishedThread($thread_id))
{
fclose($this->open_pipes[$thread_id][1]);
proc_close($thread);
}
function checkFinishedThread($thread_id)
{
$test = stream_get_meta_data($this->open_pipes[$thread_id][1]);
if($test['eof'] == 1)
return true;
return false;
}