PHP如何模拟SIGPIPE?

PHP如何模拟SIGPIPE?,php,sigpipe,Php,Sigpipe,我的环境: Ubuntu 18.04 LTS PHP7.2.2ZTS无调试 我有一个大型应用程序,其中有时会发生断管错误。 我想处理它,但为此,我需要模拟这个错误进行开发。我该怎么做 我试过: posix_kill(posix_getpid(), SIGPIPE); while(1) { sleep(5); } 此外: 但脚本继续工作 预期结果: Thread 1 "php" received signal SIGPIPE, Broken pipe. 脚本应该停止。信号\u示例。ph

我的环境: Ubuntu 18.04 LTS PHP7.2.2ZTS无调试

我有一个大型应用程序,其中有时会发生
断管
错误。 我想处理它,但为此,我需要模拟这个错误进行开发。我该怎么做

我试过:

posix_kill(posix_getpid(), SIGPIPE);
while(1) {
    sleep(5);
}
此外:

但脚本继续工作

预期结果:

Thread 1 "php" received signal SIGPIPE, Broken pipe.

脚本应该停止。

信号\u示例。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);
}
杀戮-13990:

artemev@Vitaly-PC:~/project/example$ php signal_example.php 
Process 990 "php" received signal SIGPIPE, Broken pipe.
artemev@Vitaly-PC:~/project/example$ php signal_example.php 
Process 990 "php" received signal SIGPIPE, Broken pipe.