This is an old revision of the document!
PHP RFC: Additional Context in pcntl_signal Handler
- Version: 0.1
- Date: 2016-06-14
- Author: David Walker dave@mudsite.com, Bishop Bettini bishop@php.net
- Status: Draft
- First Published at: http://wiki.php.net/rfc/additional-context-in-pcntl-signal-handler
Introduction
Modern UNIX kernels include additional context when delivering a signal, however the callable handler for pcntl_signal does not receive this information. Developers coordinating multiple processes through signals must arrange to gather and send this same information using alternative channels, which is time-consuming, error-prone, and unnecessary.
Proposal
Currently the signal handler receives only one formal argument, the number of the signal sent. This proposal would add a second formal argument, an array of signal info as provided by the kernel, as seen here:
<?php pcntl_signal(SIGUSR1, function ($signo, $siginfo) { print_r($siginfo); }); posix_kill(0, SIGUSR1);
The $siginfo
array may contain one or more of the following keys, depending upon the system support for signal information and the nature of the sent signal:
si_signo
, the signal number being sent (duplicates the first argument).si_code
, the signal code, which depends upon the signal sent and provides context-specific reason why the signal was sent.si_value
, the value for the code, if appropriate.
These are generally useful to a wide range of process interactions.
Backward Incompatible Changes
There are no backward compatibility breaks.
Proposed PHP Version(s)
Next PHP 7.x.
RFC Impact
To SAPIs
TODO
To Existing Extensions
The pcntl
extension will be updated.
To Opcache
TODO
Open Issues
- Should we send
null
if the underlying system doesn't supportsiginfo_t
, or should we sendarray ()
? - Should we normalize the array keys (for example,
si_signo
is removed because it's a duplicate, andsi_code
becomes justcode
)? - Are there any effects to opcache or web SAPI?
Proposed Voting Choices
Vote shall be Yes or No to deliver kernel-provided additional context to the pcntl_signal
handler.
Requires a 50%+1 majority.