Skip to content

Fix pcntl_signal() fatal error for SIGKILL and SIGSTOP - #25513

Open
lacatoire wants to merge 2 commits into
php:PHP-8.4from
lacatoire:fix/pcntl-signal-sigkill-sigstop-84
Open

lacatoire wants to merge 2 commits into
php:PHP-8.4from
lacatoire:fix/pcntl-signal-sigkill-sigstop-84

Conversation

@lacatoire

@lacatoire lacatoire commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

pcntl_signal() on SIGKILL or SIGSTOP aborts the script with an uncatchable fatal error raised by zend_sigaction(), because sigaction() always fails for these signals. The SIG_ERR handling in pcntl_signal() is never reached. Return false with the usual "Error assigning signal" warning instead.

To reproduce:

var_dump(pcntl_signal(SIGKILL, SIG_IGN));
echo "alive\n";

Before (8.4.26): Fatal error: Error installing signal handler for 9

After: Warning: pcntl_signal(): Error assigning signal, bool(false), alive

pcntl_signal() on SIGKILL or SIGSTOP aborted the script with an
uncatchable E_ERROR raised by zend_sigaction(), because sigaction()
always fails for these signals. The SIG_ERR handling in pcntl_signal()
was never reached. Return false with the usual "Error assigning signal"
warning and EINVAL as last error instead.

Fixes: php#2863
Comment thread ext/pcntl/pcntl.c Resolved
An invalid handler for SIGKILL or SIGSTOP returned false instead of throwing
the TypeError or ValueError raised for every other signal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants