Skip to content

Commit

Permalink
update async_master.php.
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Jul 17, 2015
1 parent f0d4653 commit 91b6b21
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions examples/process/async_master.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ function onReceive($pipe) {
global $workers;
$worker = $workers[$pipe];
$data = $worker->read();
if ($data == false)
{
//表示子进程已关闭,回收它
$status = swoole_process::wait();
echo "Worker#{$status['pid']} exit\n";
}
else
{
echo "RECV: ".$data;
}
echo "RECV: " . $data;
}

//循环创建进程
Expand All @@ -37,6 +28,12 @@ function onReceive($pipe) {
$workers[$process->pipe] = $process;
}

swoole_process::signal(SIGCHLD, function(){
//表示子进程已关闭,回收它
$status = swoole_process::wait();
echo "Worker#{$status['pid']} exit\n";
});

//将子进程的管道加入EventLoop
foreach($workers as $process)
{
Expand Down

0 comments on commit 91b6b21

Please sign in to comment.