This is an old revision of the document!

PHP RFC: Additional Context in pcntl_signal Handler


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.


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:

pcntl_signal(SIGUSR1, function ($signo, $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 Existing Extensions

The pcntl extension will be updated.

To Opcache


Open Issues

  • Should we send null if the underlying system doesn't support siginfo_t, or should we send array ()?
  • Should we normalize the array keys (for example, si_signo is removed because it's a duplicate, and si_code becomes just code)?
  • 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.

Patches and Tests


rfc/additional-context-in-pcntl-signal-handler.1466043185.txt.gz · Last modified: 2017/09/22 13:28 (external edit)