我在我的代码中使用了 pcntl 扩展,如下所示:我将处理程序绑定到某个信号,例如 SIGUSR1,并有一个向我的应用程序发送信号的脚本。
pcntl_signal(SIGUSR1, function ($signo){
echo 'Signal:' . $signo . PHP_EOL;
});
我有这样一个错误:
stream_get_contents(): Failure 'would block' (-9)
我还有一个通过 ssh 执行远程命令的代码(功能的一部分):
$stream = ssh2_exec(
$this->connection,
$command,
$options['pty'],
$options['env'],
$options['width'],
$options['height'],
$options['width_height_type']
);
if ($options['waitOut']) {
stream_set_blocking($stream, true);
如果在此处引发信号,则会出现以下错误:“Failure 'would block' (-9)”
$output = stream_get_contents($stream);
}
fclose($stream);
return $output;
有没有办法避免这种情况?