嘿,我一直在使用proc_open很多最近,它從不等待其在移動之前完成完成。確保你指定的管道,而不是隻使用一個空的數組()
$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;
}
是的,我有同樣的問題是扔我離開,因爲我的PHP腳本實際上並沒有等待,我只是以爲這是因爲本應該完成的Perl腳本仍在運行......似乎在做一個命令行殺是一個很好的路線 – Rick 2010-08-07 21:30:15
doe()實際上是一個回聲,忘記了功能。 – 2010-08-08 00:56:33