(PHP 5 >= 5.3.0)
pcntl_signal_dispatch — 调用等待信号的处理器
成功时返回 TRUE
, 或者在失败时返回 FALSE
。
Example #1 pcntl_signal_dispatch() 示例
<?php
echo "安装信号处理器...\n";
pcntl_signal(SIGHUP, function($signo) {
echo "信号处理器被调用\n";
});
echo "为自己生成SIGHUP信号...\n";
posix_kill(posix_getpid(), SIGHUP);
echo "分发...\n";
pcntl_signal_dispatch();
echo "完成\n";
?>
以上例程的输出类似于:
安装信号处理器... 为自己生成SIGHUP信号... 分发... 信号处理器被调用 完成
webmaster at ajeux dot com (2009-08-10 10:50:20)
If you are running PHP as CLI and as a "daemon" (i.e. in a loop), this function must be called in each loop to check if new signals are waiting dispatching.