diff options
author | Dennis Birkholz <dennis@birkholz.biz> | 2015-08-05 16:42:42 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-03-09 15:59:09 +0100 |
commit | d0c8aba3d868d59a75489addb056d6be5b0b5f47 (patch) | |
tree | 22cec623db26eba8c26ea8d4d14bf216fcf4eb73 | |
parent | 85243eea350d81e291e9c8d4b349b9f65fb7291d (diff) | |
download | php-git-d0c8aba3d868d59a75489addb056d6be5b0b5f47.tar.gz |
Pcntl: Make realtime signals available
Expose constants SIGRTMIN and SIGRTMAX and adjust range checks to
support realtime signals.
-rw-r--r-- | ext/pcntl/pcntl.c | 20 | ||||
-rw-r--r-- | 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 <errno.h> +#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 |