Skip to content

Commit fcbcab2

Browse files
committed
pcntl_signal_get_handler() update.
deduplicated max signals computation by using globals
1 parent 44533b1 commit fcbcab2

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

ext/pcntl/pcntl.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ PHP_RINIT_FUNCTION(pcntl)
212212
PCNTL_G(last_error) = 0;
213213
PCNTL_G(num_signals) = NSIG;
214214
#ifdef SIGRTMAX
215-
/* At least FreeBSD reports an incorrecrt NSIG that does not include realtime signals.
215+
/* At least FreeBSD reports an incorrect NSIG that does not include realtime signals.
216216
* As SIGRTMAX may be a dynamic value, adjust the value in INIT. */
217217
if (NSIG < SIGRTMAX + 1) {
218218
PCNTL_G(num_signals) = SIGRTMAX + 1;
@@ -875,17 +875,8 @@ PHP_FUNCTION(pcntl_signal_get_handler)
875875
Z_PARAM_LONG(signo)
876876
ZEND_PARSE_PARAMETERS_END();
877877

878-
// note: max signal on mac is SIGUSR2 (31), no real time signals.
879-
int sigmax = NSIG - 1;
880-
#if defined(SIGRTMAX)
881-
// oddily enough, NSIG on freebsd reports only 32 whereas SIGRTMIN starts at 65.
882-
if (sigmax < SIGRTMAX) {
883-
sigmax = SIGRTMAX;
884-
}
885-
#endif
886-
887-
if (signo < 1 || signo > sigmax) {
888-
zend_argument_value_error(1, "must be between 1 and %d", sigmax);
878+
if (signo < 1 || signo >= PCNTL_G(num_signals)) {
879+
zend_argument_value_error(1, "must be between 1 and %d", PCNTL_G(num_signals) - 1);
889880
RETURN_THROWS();
890881
}
891882

0 commit comments

Comments
 (0)