|
47 | 47 | #endif
|
48 | 48 |
|
49 | 49 | #ifndef NSIG
|
50 |
| -# ifdef SIGRTMAX |
51 |
| -# define NSIG (SIGRTMAX + 1) |
52 |
| -# else |
53 |
| -# define NSIG 32 |
54 |
| -# endif |
| 50 | +# define NSIG 32 |
55 | 51 | #endif
|
56 | 52 |
|
57 | 53 | ZEND_DECLARE_MODULE_GLOBALS(pcntl)
|
@@ -430,6 +426,14 @@ PHP_RINIT_FUNCTION(pcntl)
|
430 | 426 | PCNTL_G(head) = PCNTL_G(tail) = PCNTL_G(spares) = NULL;
|
431 | 427 | PCNTL_G(async_signals) = 0;
|
432 | 428 | PCNTL_G(last_error) = 0;
|
| 429 | + PCNTL_G(num_signals) = NSIG; |
| 430 | +#ifdef SIGRTMAX |
| 431 | + /* At least FreeBSD reports an incorrecrt NSIG that does not include realtime signals. |
| 432 | + * As SIGRTMAX may be a dynamic value, adjust the value in INIT. */ |
| 433 | + if (NSIG < SIGRTMAX + 1) { |
| 434 | + PCNTL_G(num_signals) = SIGRTMAX + 1; |
| 435 | + } |
| 436 | +#endif |
433 | 437 | return SUCCESS;
|
434 | 438 | }
|
435 | 439 |
|
@@ -900,16 +904,16 @@ PHP_FUNCTION(pcntl_signal)
|
900 | 904 | RETURN_THROWS();
|
901 | 905 | }
|
902 | 906 |
|
903 |
| - if (signo >= NSIG) { |
904 |
| - zend_argument_value_error(1, "must be less than %d", NSIG); |
| 907 | + if (signo >= PCNTL_G(num_signals)) { |
| 908 | + zend_argument_value_error(1, "must be less than %d", PCNTL_G(num_signals)); |
905 | 909 | RETURN_THROWS();
|
906 | 910 | }
|
907 | 911 |
|
908 | 912 | if (!PCNTL_G(spares)) {
|
909 | 913 | /* since calling malloc() from within a signal handler is not portable,
|
910 | 914 | * pre-allocate a few records for recording signals */
|
911 | 915 | int i;
|
912 |
| - for (i = 0; i < NSIG; i++) { |
| 916 | + for (i = 0; i < PCNTL_G(num_signals); i++) { |
913 | 917 | struct php_pcntl_pending_signal *psig;
|
914 | 918 |
|
915 | 919 | psig = emalloc(sizeof(*psig));
|
@@ -1037,7 +1041,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
|
1037 | 1041 | RETURN_THROWS();
|
1038 | 1042 | }
|
1039 | 1043 |
|
1040 |
| - for (signo = 1; signo < NSIG; ++signo) { |
| 1044 | + for (signo = 1; signo < PCNTL_G(num_signals); ++signo) { |
1041 | 1045 | if (sigismember(&oldset, signo) != 1) {
|
1042 | 1046 | continue;
|
1043 | 1047 | }
|
|
0 commit comments