Bug #79994 [Opn]: pcntl_signal_get_handler() returns SIG_DFL for externally ignored signals
| From: | weirdan at gmail dot com | Date: | Tue, 18 Aug 2020 21:21:42 +0000 |
| Subject: | Bug #79994 [Opn]: pcntl_signal_get_handler() returns SIG_DFL for externally ignored signals | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-228656@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79994&edit=1
ID: 79994
User updated by: weirdan at gmail dot com
Reported by: weirdan at gmail dot com
Summary: pcntl_signal_get_handler() returns SIG_DFL for
externally ignored signals
Status: Open
Type: Bug
Package: PCNTL related
Operating System: Linux (Debian/sid)
PHP Version: 7.4.9
Block user comment: N
Private report: N
New Comment:
It should return SIG_IGN in this case.
Previous Comments:
------------------------------------------------------------------------
[2020-08-18 21:18:18] requinix@php.net
Not a bug, but I'll get to that.
First, a question: what should pcntl_signal_get_handler() be returning?
------------------------------------------------------------------------
[2020-08-18 21:07:57] weirdan at gmail dot com
Description:
------------
Originally discovered by John Stevenson here: https://github.com/composer/xdebug-handler/issues/109#issuecomment-675462698
When signal is set to be ignored by the process that calls php binary, pcntl_signal_get_handler()
run in the context of that binary reports that same signal as using default handler (SIG_DFL).
However it's clearly doesn't use default handler, as can demonstrated by the script below.
If it was using default handler, you'd be able to abort the script with Ctrl-C, but you
can't.
PS: use Ctrl-\ to stop it.
Test script:
---------------
<?php
var_dump(
"Is default handler is used for sigint?",
pcntl_signal_get_handler(SIGINT) === SIG_DFL
);
while (true) {
echo ".";
sleep(2);
}
// Run it as follows (in bash/zsh):
// $ trap "" SIGINT; php test.php; trap - SIGINT;
Expected result:
----------------
string(38) "Is default handler is used for sigint?"
bool(false)
..................
Actual result:
--------------
string(38) "Is default handler is used for sigint?"
bool(true)
..................
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79994&edit=1