Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
rfc:zendsignals [2008/08/01 11:40] – lucas | rfc:zendsignals [2009/11/21 05:59] – Updated patches. shire |
---|
* Status: Under Discussion | * Status: Under Discussion |
* 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-0808010408.patch|PHP_5_3_0 patch]] (08-01-2008). | * 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 ===== |
===== 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 === |
- 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-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-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]]) |