Skip to content

Commit 5ecbb1b

Browse files
erkiaarnaud-lb
authored andcommitted
Fix GH-9298: remove all registered signal handlers in pcntl RSHUTDOWN
1 parent a2dcb03 commit 5ecbb1b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ext/pcntl/pcntl.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,18 @@ PHP_MSHUTDOWN_FUNCTION(pcntl)
485485
PHP_RSHUTDOWN_FUNCTION(pcntl)
486486
{
487487
struct php_pcntl_pending_signal *sig;
488+
zend_long signo;
489+
zval *handle;
490+
491+
/* Reset all signals to their default disposition */
492+
ZEND_HASH_FOREACH_NUM_KEY_VAL(&PCNTL_G(php_signal_table), signo, handle) {
493+
if (Z_TYPE_P(handle) != IS_LONG || Z_LVAL_P(handle) != (zend_long)SIG_DFL) {
494+
php_signal(signo, (Sigfunc *)(zend_long)SIG_DFL, 0);
495+
}
496+
} ZEND_HASH_FOREACH_END();
488497

489-
/* FIXME: if a signal is delivered after this point, things will go pear shaped;
490-
* need to remove signal handlers */
491498
zend_hash_destroy(&PCNTL_G(php_signal_table));
499+
492500
while (PCNTL_G(head)) {
493501
sig = PCNTL_G(head);
494502
PCNTL_G(head) = sig->next;
@@ -499,6 +507,7 @@ PHP_RSHUTDOWN_FUNCTION(pcntl)
499507
PCNTL_G(spares) = sig->next;
500508
efree(sig);
501509
}
510+
502511
return SUCCESS;
503512
}
504513

0 commit comments

Comments
 (0)