标签:
1、捕获子进程退出(监听SIGCHLD信号,然后调用 pcntl_wait 函数)
declare(ticks=1); pcntl_signal(SIGCHLD, "sig_handler"); function sig_handler($signo) { switch ($signo) { case SIGCHLD: $status = 0; $child_id = pcntl_wait($status); echo sprintf("child exit id: {$child_id} \n"); exit(0); break; default: echo ‘uncaugh signal !‘; } } $pid = pcntl_fork(); if($pid>0) { echo sprintf("fork child id: {$pid} \n"); while(1){ sleep(1); } }else{ echo "child exit \n"; }
标签:
原文地址:http://www.cnblogs.com/siqi/p/4475080.html