我的环境:Ubuntu18.04 LTS PHP 7.2.2 ZTS不调试
我有一个很大的应用程序,有时会发生Broken pipe错误。我想要处理它,但为此,我需要模拟这个错误来进行开发。我怎么能这么做?
我试过:
posix_kill(posix_getpid(), SIGPIPE);
while(1) {
sleep(5);
}另外:
sudo kill -13 pid但剧本一直在工作。
预期结果:
Thread 1 "php" received signal SIGPIPE, Broken pipe.脚本应该被阻止。
发布于 2019-05-28 10:07:38
signal_example.php:
pcntl_async_signals(true);
pcntl_signal(SIGPIPE, function (int $signo) {
echo 'Process ' . posix_getpid() . ' "php" received signal SIGPIPE, Broken pipe.';
exit;
});
while (1) {
sleep(1);
}杀害-13 990人:
artemev@Vitaly-PC:~/project/example$ php signal_example.php
Process 990 "php" received signal SIGPIPE, Broken pipe.https://stackoverflow.com/questions/56339327
复制相似问题