Reputation: 3663
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
Upvotes: 2
Views: 1349
Reputation: 3663
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
Upvotes: 2