From d0c8aba3d868d59a75489addb056d6be5b0b5f47 Mon Sep 17 00:00:00 2001 From: Dennis Birkholz Date: Wed, 5 Aug 2015 16:42:42 +0200 Subject: [PATCH] Pcntl: Make realtime signals available Expose constants SIGRTMIN and SIGRTMAX and adjust range checks to support realtime signals. --- ext/pcntl/pcntl.c | 20 +++++++++++++++++--- ext/pcntl/php_signal.h | 7 ------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index a1ac06982d..fd8c506738 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -46,6 +46,14 @@ #include +#ifndef NSIG +# ifdef SIGRTMAX +# define NSIG (SIGRTMAX + 1) +# else +# define NSIG 32 +# endif +#endif + ZEND_DECLARE_MODULE_GLOBALS(pcntl) static PHP_GINIT_FUNCTION(pcntl); @@ -301,6 +309,12 @@ void php_register_signal_constants(INIT_FUNC_ARGS) REGISTER_LONG_CONSTANT("SIGSYS", (zend_long) SIGSYS, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SIGBABY", (zend_long) SIGSYS, CONST_CS | CONST_PERSISTENT); #endif +#ifdef SIGRTMIN + REGISTER_LONG_CONSTANT("SIGRTMIN", (zend_long) SIGRTMIN, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef SIGRTMAX + REGISTER_LONG_CONSTANT("SIGRTMAX", (zend_long) SIGRTMAX, CONST_CS | CONST_PERSISTENT); +#endif #if HAVE_GETPRIORITY || HAVE_SETPRIORITY REGISTER_LONG_CONSTANT("PRIO_PGRP", PRIO_PGRP, CONST_CS | CONST_PERSISTENT); @@ -984,7 +998,7 @@ PHP_FUNCTION(pcntl_signal) return; } - if (signo < 1 || signo > 32) { + if (signo < 1 || signo >= NSIG) { php_error_docref(NULL, E_WARNING, "Invalid signal"); RETURN_FALSE; } @@ -993,7 +1007,7 @@ PHP_FUNCTION(pcntl_signal) /* since calling malloc() from within a signal handler is not portable, * pre-allocate a few records for recording signals */ int i; - for (i = 0; i < 32; i++) { + for (i = 0; i < NSIG; i++) { struct php_pcntl_pending_signal *psig; psig = emalloc(sizeof(*psig)); @@ -1112,7 +1126,7 @@ PHP_FUNCTION(pcntl_sigprocmask) } else { zend_hash_clean(Z_ARRVAL_P(user_oldset)); } - for (signo = 1; signo < MAX(NSIG-1, SIGRTMAX); ++signo) { + for (signo = 1; signo < NSIG; ++signo) { if (sigismember(&oldset, signo) != 1) { continue; } diff --git a/ext/pcntl/php_signal.h b/ext/pcntl/php_signal.h index dc9ef7a691..f8aef0c6cc 100644 --- a/ext/pcntl/php_signal.h +++ b/ext/pcntl/php_signal.h @@ -22,13 +22,6 @@ #ifndef PHP_SIGNAL_H #define PHP_SIGNAL_H -#ifndef NSIG -# define NSIG 32 -#endif -#ifndef SIGRTMAX -# define SIGRTMAX 64 -#endif - #ifdef HAVE_STRUCT_SIGINFO_T typedef void Sigfunc(int, siginfo_t*, void*); #else -- 2.40.0