douwen3973 2017-08-17 19:34
浏览 682

在php7.1上配置pcntl_signal

I've faced the issue with pcntl_signal after migration to php71.

I've installed php71 (brew install php71 --with-httpd24 --with-imap --with-postgresql) and its pcntl extension (brew install homebrew/php/php71-pcntl) but pcntl_signal() still not working

Please help me because i don't understand why it does not work.

P.S. I'm running the same code which was working on php56

  • 写回答

1条回答 默认 最新

  • drxnfdx798517235 2017-08-17 20:38
    关注

    After some research I found out that a new function called pcntl_async_signals() has been introduced in php71, so now instead of declare(ticks = 1); at the beginning of the file you have use pcntl_async_signals(true);

    For my particular case I fixed if like:

    <?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
    }
    

    P.S. Link to documentation

    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题