46
46
47
47
#include <errno.h>
48
48
49
+ #ifndef NSIG
50
+ # ifdef SIGRTMAX
51
+ # define NSIG (SIGRTMAX + 1)
52
+ # else
53
+ # define NSIG 32
54
+ # endif
55
+ #endif
56
+
49
57
ZEND_DECLARE_MODULE_GLOBALS (pcntl )
50
58
static PHP_GINIT_FUNCTION (pcntl );
51
59
@@ -301,6 +309,12 @@ void php_register_signal_constants(INIT_FUNC_ARGS)
301
309
REGISTER_LONG_CONSTANT ("SIGSYS" , (zend_long ) SIGSYS , CONST_CS | CONST_PERSISTENT );
302
310
REGISTER_LONG_CONSTANT ("SIGBABY" , (zend_long ) SIGSYS , CONST_CS | CONST_PERSISTENT );
303
311
#endif
312
+ #ifdef SIGRTMIN
313
+ REGISTER_LONG_CONSTANT ("SIGRTMIN" , (zend_long ) SIGRTMIN , CONST_CS | CONST_PERSISTENT );
314
+ #endif
315
+ #ifdef SIGRTMAX
316
+ REGISTER_LONG_CONSTANT ("SIGRTMAX" , (zend_long ) SIGRTMAX , CONST_CS | CONST_PERSISTENT );
317
+ #endif
304
318
305
319
#if HAVE_GETPRIORITY || HAVE_SETPRIORITY
306
320
REGISTER_LONG_CONSTANT ("PRIO_PGRP" , PRIO_PGRP , CONST_CS | CONST_PERSISTENT );
@@ -984,7 +998,7 @@ PHP_FUNCTION(pcntl_signal)
984
998
return ;
985
999
}
986
1000
987
- if (signo < 1 || signo > 32 ) {
1001
+ if (signo < 1 || signo >= NSIG ) {
988
1002
php_error_docref (NULL , E_WARNING , "Invalid signal" );
989
1003
RETURN_FALSE ;
990
1004
}
@@ -993,7 +1007,7 @@ PHP_FUNCTION(pcntl_signal)
993
1007
/* since calling malloc() from within a signal handler is not portable,
994
1008
* pre-allocate a few records for recording signals */
995
1009
int i ;
996
- for (i = 0 ; i < 32 ; i ++ ) {
1010
+ for (i = 0 ; i < NSIG ; i ++ ) {
997
1011
struct php_pcntl_pending_signal * psig ;
998
1012
999
1013
psig = emalloc (sizeof (* psig ));
@@ -1112,7 +1126,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
1112
1126
} else {
1113
1127
zend_hash_clean (Z_ARRVAL_P (user_oldset ));
1114
1128
}
1115
- for (signo = 1 ; signo < MAX ( NSIG - 1 , SIGRTMAX ) ; ++ signo ) {
1129
+ for (signo = 1 ; signo < NSIG ; ++ signo ) {
1116
1130
if (sigismember (& oldset , signo ) != 1 ) {
1117
1131
continue ;
1118
1132
}
0 commit comments