迁移到 php71 后,我遇到了 pcntl_signal
问题。
我已经安装了 php71 (brew install php71 --with-httpd24 --with-imap --with-postgresql
) 及其 pcntl 扩展 (brew install homebrew/php/php71 -pcntl
),但 pcntl_signal()
仍然不起作用
请帮助我,因为我不明白为什么它不起作用。
P.S.我正在运行与 php56 相同的代码
最佳答案
经过一番研究,我发现 php71 中引入了一个名为 pcntl_async_signals()
的新函数,因此现在代替 declare(ticks = 1);
您使用的文件开头 pcntl_async_signals(true);
对于我的特殊情况,我修复了以下情况:
<?php
namespace AppBundle\Command;
if (function_exists('pcntl_async_signals')) {
// for php 7.1
pcntl_async_signals(true);
} else {
// for php 4.3.0+ (up to 7.0)
declare(ticks = 1);
}
abstract class AbstractCommand {
// use pcntl_signal() where you need
}
附注链接至documentation
关于php - 在php7.1上配置pcntl_signal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45743615/