mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
ext/pcntl: Fix signal table updated before php_signal4 succeeds in pcntl_signal
Move the signal table update after the php_signal4 call, mirroring what is already done in the SIG_DFL/SIG_IGN (integer) code path. This prevents a stale entry in the table if sigaction fails. close GH-21270
This commit is contained in:
4
NEWS
4
NEWS
@@ -43,9 +43,11 @@ PHP NEWS
|
||||
|
||||
- PCNTL:
|
||||
. Fixed pcntl_setns() internal errors handling regarding errnos.
|
||||
(David Carlier)
|
||||
(David Carlier/ndossche)
|
||||
. Fixed cpuset leak in pcntl_setcpuaffinity on out-of-range CPU ID
|
||||
on NetBSD/Solaris platforms. (David Carlier)
|
||||
. Fixed pcntl_signal() signal table registering the callback first
|
||||
OS-wise before the internal list. (David Carlier)
|
||||
|
||||
- PDO_PGSQL:
|
||||
. Fixed bug GH-21055 (connection attribute status typo for GSS negotiation).
|
||||
|
||||
@@ -798,15 +798,16 @@ PHP_FUNCTION(pcntl_signal)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
/* Add the function name to our signal table */
|
||||
handle = zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle);
|
||||
Z_TRY_ADDREF_P(handle);
|
||||
|
||||
/* Register with the OS first so that on failure we don't record a handler that was never installed */
|
||||
if (php_signal4(signo, pcntl_signal_handler, (int) restart_syscalls, 1) == (void *)SIG_ERR) {
|
||||
PCNTL_G(last_error) = errno;
|
||||
php_error_docref(NULL, E_WARNING, "Error assigning signal");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* Add the function name to our signal table */
|
||||
handle = zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle);
|
||||
Z_TRY_ADDREF_P(handle);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
Reference in New Issue
Block a user