Skip to content

Commit 9575968

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: [ci skip] NEWS [ci skip] NEWS Fix GH-9298: remove all registered signal handlers in pcntl RSHUTDOWN
2 parents e0e347b + 9d0f5bc commit 9575968

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
@@ -140,10 +140,18 @@ PHP_MSHUTDOWN_FUNCTION(pcntl)
140140
PHP_RSHUTDOWN_FUNCTION(pcntl)
141141
{
142142
struct php_pcntl_pending_signal *sig;
143+
zend_long signo;
144+
zval *handle;
145+
146+
/* Reset all signals to their default disposition */
147+
ZEND_HASH_FOREACH_NUM_KEY_VAL(&PCNTL_G(php_signal_table), signo, handle) {
148+
if (Z_TYPE_P(handle) != IS_LONG || Z_LVAL_P(handle) != (zend_long)SIG_DFL) {
149+
php_signal(signo, (Sigfunc *)(zend_long)SIG_DFL, 0);
150+
}
151+
} ZEND_HASH_FOREACH_END();
143152

144-
/* FIXME: if a signal is delivered after this point, things will go pear shaped;
145-
* need to remove signal handlers */
146153
zend_hash_destroy(&PCNTL_G(php_signal_table));
154+
147155
while (PCNTL_G(head)) {
148156
sig = PCNTL_G(head);
149157
PCNTL_G(head) = sig->next;
@@ -154,6 +162,7 @@ PHP_RSHUTDOWN_FUNCTION(pcntl)
154162
PCNTL_G(spares) = sig->next;
155163
efree(sig);
156164
}
165+
157166
return SUCCESS;
158167
}
159168

0 commit comments

Comments
 (0)