function daemonize()
{
$pid = pcntl_fork();
if($pid == -1){
die('fork fail!');
}elseif($pid > 0){
exit(0);
}
umask( 0);
posix_setsid();
$pid = pcntl_fork();
if(-1 == $pid){
die('fail fail child!');
}elseif($pid > 0){
exit(0);
}
}
父进程退出,子进程中创建一个新会话,独立出来脱离控制