rfc:additional-context-in-pcntl-signal-handler

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:additional-context-in-pcntl-signal-handler [2016/06/20 15:05] – Clarified behavior on systems with siginfo_t. Added more documentation on use cases and available fields. bishoprfc:additional-context-in-pcntl-signal-handler [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== PHP RFC: Additional Context in pcntl_signal Handler ====== ====== PHP RFC: Additional Context in pcntl_signal Handler ======
-  * Version: 0.2+  * Version: 1.0
   * Date: 2016-06-14   * Date: 2016-06-14
-  * Author: David Walker <dave@mudsite.com>, Bishop Bettini <bishop@php.net> +  * Authors: David Walker <dave@mudsite.com>, Bishop Bettini <bishop@php.net> 
-  * Status: Draft+  * Status: Accepted
   * First Published at: http://wiki.php.net/rfc/additional-context-in-pcntl-signal-handler   * First Published at: http://wiki.php.net/rfc/additional-context-in-pcntl-signal-handler
  
Line 21: Line 21:
     printf('USR1 from %s', $siginfo['pid'] ?? 'unknown');     printf('USR1 from %s', $siginfo['pid'] ?? 'unknown');
 }); });
-posix_kill(0, SIGUSR1);+posix_kill(posix_getpid(), SIGUSR1); 
 +pcntl_signal_dispatch();
 </file> </file>
  
Line 39: Line 40:
   * **''mtime''**, the time of last data modification, if appropriate for the signal.   * **''mtime''**, the time of last data modification, if appropriate for the signal.
  
-Like other ''pcntl'' functions that map internal ''signal.h'' names into PHP keysthe leading ''si_'' has been removed. (That isin the C documentation "''si_signo''" becomes "''signo''" in PHP.) However, this does not apply to the values of the ''code'' field, as those represent system-specific constants that follow no normative naming convention.+The naming of ''$siginfo'' and its keys comes from the ''pcntl_sigwaitinfo'' implementation. (So for example, "''signo''" in PHP comes from "''si_signo''" in the C structure, the leading "si_" having been removed by the PHP engine.) Name normalization does not apply to the values of the ''code'' field, as those represent system-specific values that follow no normative naming convention.
  
 Some older systems not conforming to [[https://standards.ieee.org/findstds/standard/1003.1-2001.html|POSIX.1-2001]] (where this structure was formally codified) may not support passing the additional context. In such case, PHP will pass ''null'' as the second argument to the handler. Some older systems not conforming to [[https://standards.ieee.org/findstds/standard/1003.1-2001.html|POSIX.1-2001]] (where this structure was formally codified) may not support passing the additional context. In such case, PHP will pass ''null'' as the second argument to the handler.
Line 51: Line 52:
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
  
-Next PHP 7.x.+Next PHP 7.x, currently 7.1.
  
  
Line 69: Line 70:
 None. None.
  
 +===== Discussion =====
 +
 +Instead of updating ''pcntl_signal'', it was suggested to add a method ''pcntl_sigaction'', which would "keep maximum compatibility and eliminate unnecessary additional overhead". This suggestion was later withdrawn as perhaps adding more complication than the patch itself, though a later [[https://github.com/php/php-src/pull/1985|PR]] addressed parts of the suggestion. [[https://www.mail-archive.com/internals@lists.php.net/msg86504.html|Reference.]]
 +
 +Performance was raised as a concern. Having run tests through callgrind there is an additional 0.0001% cost for the feature. The profiled code defined an empty function, set the handler, and triggered the signal. Passing the additional information resulted in 2000 extra instructions, out of a total 13 million. This seems negligible compared to the cost of acquiring the same information through other means (eg message queues, temporary files, etc.).
  
 ===== Open Issues ===== ===== Open Issues =====
Line 80: Line 86:
 Requires a 50%+1 majority. Requires a 50%+1 majority.
  
 +<doodle title="Provide additional context in pcntl signal handler?" auth="bishopb" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
 +
 +Voting shall close one week after opening on Thursday, July 14, 2016 at 23:59 UTC.
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
  
-  * [[https://github.com/bp1222/php-src|Work in Progress]]+  * [[https://github.com/php/php-src/pull/1993|Implementation with tests.]]
  
  
Line 89: Line 101:
  
   * [[https://marc.info/?l=php-internals&m=146584196929126&w=2|Initial ping to php.internals]]   * [[https://marc.info/?l=php-internals&m=146584196929126&w=2|Initial ping to php.internals]]
 +  * [[https://marc.info/?l=php-internals&m=146670242109688&w=2|Discussion]]
rfc/additional-context-in-pcntl-signal-handler.1466435148.txt.gz · Last modified: 2017/09/22 13:28 (external edit)