com php-src: Pcntl: Make realtime signals available: ext/pcntl/pcntl.c ext/pcntl/php_signal.h

[email protected] (Nikita Popov)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    d0c8aba3d868d59a75489addb056d6be5b0b5f47
Author:    Dennis Birkholz <[email protected]>         Wed, 5 Aug 2015 16:42:42 +0200
Committer: Nikita Popov <[email protected]>      Thu, 9 Mar 2017 15:59:09 +0100
Parents:   85243eea350d81e291e9c8d4b349b9f65fb7291d
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=d0c8aba3d868d59a75489addb056d6be5b0b5f47

Log:
Pcntl: Make realtime signals available

Expose constants SIGRTMIN and SIGRTMAX and adjust range checks to
support realtime signals.

Changed paths:
  M  ext/pcntl/pcntl.c
  M  ext/pcntl/php_signal.h


Diff:
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index a1ac069..fd8c506 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 dc9ef7a..f8aef0c 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.