rfc:zendsignals

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:zendsignals [2008/07/29 23:38] – Added discoveries, updated patch lucasrfc:zendsignals [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 3: Line 3:
   * Date: 2008-07-05   * Date: 2008-07-05
   * Author: Lucas Nealan <lucas@facebook.com>   * Author: Lucas Nealan <lucas@facebook.com>
-  * Status: Under Discussion+  * Status: Implemented in PHP 5.4
   * First Proposed by: [[http://markmail.org/message/3jg6cwqfghdlydhy|Rasmus Lerdorf]]   * First Proposed by: [[http://markmail.org/message/3jg6cwqfghdlydhy|Rasmus Lerdorf]]
-  * Source code: [[http://sizzo.org/~screen/patches/php-5.3.0-alarms-0807291627.patch|PHP_5_3_0 patch]].+  * Source code: [[http://tekrat.com/downloads/bits/php-5.3-signals.20091120.patch|PHP_5_3 patch]] [[http://tekrat.com/downloads/bits/php-trunk-signals.20091120.patch|PHP Trunk patch]] (11-20-2009).
  
 ===== Introduction ===== ===== Introduction =====
Line 85: Line 85:
 ===== Considerations ===== ===== Considerations =====
  
-  - Zend Signal Handling support has not been implemented for ZTS enabled php builds. While this is likely to improve PHP stability under Apache 2 using the prefork MPM, there will be no such improvement under the worker MPM.+  - Limited Zend Signal Handling support has been implemented for ZTS enabled php builds. Future development is planned to add support for ZTS windows builds.
  
-  - The current implementation is not enabled by default, to enable pass --enable-zend-signals to PHP configure. 
-  
-  - The proposal has only been implemented for PHP_5_3 and will need to be ported to PHP 6. 
-  
   - For simplicity the //_zend_signal_info_t.prev// structure is implemented as a static vector of NSIG size. On some systems NSIG may not be defined and 65 will be used as the default vector size.   - For simplicity the //_zend_signal_info_t.prev// structure is implemented as a static vector of NSIG size. On some systems NSIG may not be defined and 65 will be used as the default vector size.
 +
 +  - A signal queue of ZEND_SIGNAL_QUEUE_SIZE is created to handle recieved signals within critical sections. It is initialized to support 32 signals. If more are received after this they are discarded.
  
 ===== Discoveries ===== ===== Discoveries =====
 === pcntl extension signals === === pcntl extension signals ===
-The experimental pcntl extension allows signal handlers to be defined in PHP userspace via //[[http://docs.php.net/manual/en/function.pcntl-signal.php|pctnl_signal()]]//. The handler is installed via //signal// and any previously registered handlers for the specified signal are ignored. While this is technically incompatible with Zend Signals, if a handler is installed via //pctnl_signal// for signals SIGALRM, SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2, the deferred protection offered by Zend Signals will basically be disabled for that signal number+The pcntl extension allows signal handlers to be defined in PHP userspace via //[[http://docs.php.net/manual/en/function.pcntl-signal.php|pctnl_signal()]]//. The handler is installed via //signal// and any previously registered handlers for the specified signal are ignored. While this is technically incompatible with Zend Signals, if a handler is installed via //pctnl_signal// for signals SIGALRM, SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2, the deferred protection offered by Zend Signals will basically be disabled for that signal number.
- +
-Future versions of Zend Signal should improve //zend_signal()// so extensions such as pcntl can register signals through Zend and still protect critical sections.+
  
 Note: Although --enable-pcntl states "(CLI/CGI only)" in the config.m4, there is no actual enforcement of this at compile time. The extension can be running in any SAPI. Note: Although --enable-pcntl states "(CLI/CGI only)" in the config.m4, there is no actual enforcement of this at compile time. The extension can be running in any SAPI.
 +
 +Update: pcntl has been modified to register signals via //zend_signal()// when available. Critical sections will now continue to have deferred protection even after signals are registered via pcntl.
  
 === PHP SIGCHLD signal handler === === PHP SIGCHLD signal handler ===
Line 107: Line 105:
  
 Note: When calling //wait()// or //waitpid()// within a handler the global errno may be modified. I have modified the existing handler in this patch to account for this.  Note: When calling //wait()// or //waitpid()// within a handler the global errno may be modified. I have modified the existing handler in this patch to account for this. 
- 
  
 ===== Changelog ===== ===== Changelog =====
  
-   - 2008-07-05 Lucas Nealan: Initial creation+   - 2008-07-05 Lucas Nealan: Initial creation ([[http://markmail.org/thread/di2fr6vzovagqofc|Discussed on internals]])
    - 2008-07-08 Lucas Nealan: Updated patch for php_request_shutdown order issue ([[http://sizzo.org/~screen/patches/php-5.3.0-alarms-0807051839.patch|prev patch]])    - 2008-07-08 Lucas Nealan: Updated patch for php_request_shutdown order issue ([[http://sizzo.org/~screen/patches/php-5.3.0-alarms-0807051839.patch|prev patch]])
-   - 2008-07-29 Lucas Nealan: Update to fix reentrance in handler, enable by default, stolen signal reporting ([[http://sizzo.org/~screen/patches/php-5.3.0-alarms-0807081632.patch|prev patch]]) +   - 2008-07-29 Lucas Nealan: Update patch to fix reentrance in handler, enable by default, stolen signal reporting ([[http://sizzo.org/~screen/patches/php-5.3.0-alarms-0807081632.patch|prev patch]]) 
 +   - 2008-08-01 Lucas Nealan: Update patch to fix tests, alloc/free on php startup/shutdown, ini for shutdown tests ([[http://sizzo.org/~screen/patches/php-5.3.0-alarms-0807291627.patch|prev patch]]) 
 +   - 2008-08-03 Lucas Nealan: Incorporated ZTS support by Arnaud Le Blanc, moved ini def to zend.c, added HEAD patch ([[http://sizzo.org/~screen/patches/php-5.3.0-alarms-0808010408.patch|prev patch]]) 
 +   - 2008-08-05 Arnaud Le Blanc: Added zend_sigaction() and ported PCNTL to use it. ([[http://sizzo.org/~screen/patches/php-5.3.0-alarms-0808021704.patch|PHP_5_3_0 prev patch]] [[http://sizzo.org/~screen/patches/php-HEAD-alarms-0808021832.patch|PHP_HEAD prev patch]]) 
 +   - 2008-08-12 Lucas Nealan: Update patches to latest CVS, minor TWS fixes etc. ([[http://arnaud.lb.s3.amazonaws.com/php-5.3.0-alarms-0808051122.patch|PHP_5_3_0 prev patc]] [[http://arnaud.lb.s3.amazonaws.com/php-HEAD-alarms-0808051122.patch|PHP_HEAD prev patch]]) 
 +   - 2009-11-20 Brian Shire: Updated patches for latest CVS with some fixes for bugs caused by another fix to the handling of signals during user-space shutdown functions. ([[http://sizzo.org/~screen/patches/php-5.3.0-alarms-0808121020.patch|PHP_5_3_0 prev patch]] [[http://sizzo.org/~screen/patches/php-HEAD-alarms-0808121015.patch|PHP_HEAD prev patch]])
rfc/zendsignals.1217374696.txt.gz · Last modified: 2017/09/22 13:28 (external edit)