PHP RFC: Asynchronous Signal Handling (without TICKs)
- Version: 0.9
- Date: 2016-06-24
- Author: Dmitry Stogov, firstname.lastname@example.org
- Status: Accepted
- First Published at: https://wiki.php.net/rfc/async_signals
Currently php may handle OS signals using
- synchronously, calling
- asynchronously, compiling scripts with
However, TICKs introduce huge overhead.
Zend Engine in PHP 7.1 was extended with ability of safe time-out and interrupt handling. Actually, PHP VM checks for EG(vm_interrupt) flag on each loop iteration, user function entry or internal function exit, and call callback function if necessary.
I propose to use this ability to implement asynchronous signal handling. Registered signal handlers are going to be called at some points during user script execution without any overhead.
To keep ability of synchronous signal, handling we had to introduce a new INI directive
pcntl.async_signals with default value 0. Bob pointed, that instead of INI directive, we may use function
pcntl_async_signals(bool on_off). In my opinion, this doesn't make a big difference. In first case, some PHP script may don't know the value set through php.ini. In the second, it may don't know the previous value set through
Backward Incompatible Changes
Proposed PHP Version(s)
- pcntl.async_signals=0, it's value may be changed at run-time through ini_set().
In the next major PHP version we may remove ability of manual signal handling and corresponding
pcntl.async_signals INI directive or
Proposed Voting Choices
The vote is a straight Yes/No vote, that requires a 2/3 majority. The vote began on June 28 and will finish on July 6.
An additional 1/2 majority question:
Patches and Tests
The patch is really simple: PR 1953
After the project is implemented, this section should contain
- Documentation: http://php.net/manual/en/function.pcntl-async-signals.php