Bug #79994 [NEW]: pcntl_signal_get_handler() returns SIG_DFL for externally ignored signals

From: Date: Tue, 18 Aug 2020 21:07:57 +0000
Subject: Bug #79994 [NEW]: pcntl_signal_get_handler() returns SIG_DFL for externally ignored signals
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228654@lists.php.net to get a copy of this message
From:             weirdan at gmail dot com
Operating system: Linux (Debian/sid)
PHP version:      7.4.9
Package:          PCNTL related
Bug Type:         Bug
Bug description:pcntl_signal_get_handler() returns SIG_DFL for externally ignored signals

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 bug report at https://bugs.php.net/bug.php?id=79994&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79994&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79994&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79994&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79994&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79994&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79994&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79994&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79994&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79994&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79994&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79994&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79994&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79994&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79994&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79994&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79994&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79994&r=mysqlcfg


Thread (6 messages)

« previous php.bugs (#228654) next »