Skip to content

Commit 93bbb46

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: ext/pcntl: Fix signal table updated before php_signal4 succeeds in pcntl_signal
2 parents 7b4a703 + 98258a3 commit 93bbb46

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ext/pcntl/pcntl.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,15 +846,16 @@ PHP_FUNCTION(pcntl_signal)
846846
RETURN_THROWS();
847847
}
848848

849-
/* Add the function name to our signal table */
850-
handle = zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle);
851-
Z_TRY_ADDREF_P(handle);
852-
849+
/* Register with the OS first so that on failure we don't record a handler that was never installed */
853850
if (php_signal4(signo, pcntl_signal_handler, (int) restart_syscalls, 1) == (void *)SIG_ERR) {
854851
PCNTL_G(last_error) = errno;
855852
php_error_docref(NULL, E_WARNING, "Error assigning signal");
856853
RETURN_FALSE;
857854
}
855+
856+
/* Add the function name to our signal table */
857+
handle = zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle);
858+
Z_TRY_ADDREF_P(handle);
858859
RETURN_TRUE;
859860
}
860861
/* }}} */

0 commit comments

Comments
 (0)