diff options
author | David Walker <dave@mudsite.com> | 2016-12-19 14:29:18 -0700 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2016-12-29 21:18:22 +0100 |
commit | b09c2f899ebc14029d0936d770cced10b607f84b (patch) | |
tree | e993d4f6b21c1d929bc14278c8a9e9452cceb7e1 /Zend/zend_signal.c | |
parent | 7746ed9d5f2e195e26b6e468c303dc1e86af12af (diff) | |
download | php-git-b09c2f899ebc14029d0936d770cced10b607f84b.tar.gz |
Fixed bug #73783
Bug #73783 raises an issue with signal handling when using SIG_IGN.
With PHP7.1 ZEND_SIGNALS is defaulted to on, which will for all
signals set the handler as zend_signal_handler_defer. This is
problematic for syscalls like sleep(), which will only return when the
requisite number of seconds have elapsed, or, a non-ignored signal is
raised. In this case we want to SIG_IGN SIGCHLD, however, SIG_IGN is
only stored in the SIGG(handlers) array, and the actual system level
handler is defined. This prevents proper signal ignoring when requeted.
Diffstat (limited to 'Zend/zend_signal.c')
-rw-r--r-- | Zend/zend_signal.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c index 1d8baaf0f5..605187aed2 100644 --- a/Zend/zend_signal.c +++ b/Zend/zend_signal.c @@ -198,7 +198,7 @@ static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context) #endif } } - } else if (p_sig.handler != SIG_IGN) { /* ignore SIG_IGN */ + } else { if (p_sig.flags & SA_SIGINFO) { if (p_sig.flags & SA_RESETHAND) { SIGG(handlers)[signo-1].flags = 0; @@ -234,9 +234,13 @@ ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigac } memset(&sa, 0, sizeof(sa)); - sa.sa_flags = SA_SIGINFO | (act->sa_flags & SA_FLAGS_MASK); - sa.sa_sigaction = zend_signal_handler_defer; - sa.sa_mask = global_sigmask; + if (SIGG(handlers)[signo-1].handler == (void *) SIG_IGN) { + sa.sa_sigaction = (void *) SIG_IGN; + } else { + sa.sa_flags = SA_SIGINFO | (act->sa_flags & SA_FLAGS_MASK); + sa.sa_sigaction = zend_signal_handler_defer; + sa.sa_mask = global_sigmask; + } if (sigaction(signo, &sa, NULL) < 0) { zend_error_noreturn(E_ERROR, "Error installing signal handler for %d", signo); |