使用PHP脚本来写Daemon程序(4)
$signal_flag = TRUE;
}
break;
case SIGALRM:
print date('y-m-d H:i:s', time() ) . " Caught Signal : SIGALRM - No : $signal \n";
//pcntl_exec( '/bin/ls' );
pcntl_alarm( 5 );
break;
default:
break;
}
}
function AutoStart( $signal = FALSE, $filename = 'config.php' ){
global $init_md5;
if( $signal || md5_file( $filename ) != $init_md5 ){
print "The config file has been changed, we are going to restart. \n";
$pid = pcntl_fork();
if( $pid == -1 ){
print "Fork error \n";
}else if( $pid > 0 ){
print "Parent exit \n";
exit(0);
}else{
$init_md5 = md5_file( $filename );
print "Child continue to run \n";
}
}
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>