]> granicus.if.org Git - php/commitdiff
Pcntl: Make realtime signals available
authorDennis Birkholz <dennis@birkholz.biz>
Wed, 5 Aug 2015 14:42:42 +0000 (16:42 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 9 Mar 2017 14:59:09 +0000 (15:59 +0100)
Expose constants SIGRTMIN and SIGRTMAX and adjust range checks to
support realtime signals.

ext/pcntl/pcntl.c
ext/pcntl/php_signal.h

index a1ac06982d503b3bfe07a79548c9de07152ba625..fd8c5067381e5815cb863e8308cfd8f6a640b030 100644 (file)
 
 #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;
                        }
index dc9ef7a6916e93fa5bf81436d934841da1aaf3ba..f8aef0c6cc68ef15766e7717e7cd5bc0de32a94d 100644 (file)
 #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