Skip to content

Commit 752fea8

Browse files
committed
ext/pcntl pcntl_signal_get_handler update.
The situation varies from platform to another, thus taking in account the complexity of it.
1 parent 365e211 commit 752fea8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

ext/pcntl/pcntl.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,21 @@ PHP_FUNCTION(pcntl_signal_get_handler)
692692
Z_PARAM_LONG(signo)
693693
ZEND_PARSE_PARAMETERS_END();
694694

695-
if (signo < 1 || signo > 32) {
696-
zend_argument_value_error(1, "must be between 1 and 32");
695+
#if !defined(__APPLE__)
696+
static int sigmax = NSIG;
697+
#if defined(SIGRTMAX)
698+
// oddily enough, NSIG on freebsd reports only 32 whereas SIGRTMIN starts at 65.
699+
if (sigmax < SIGRTMAX) {
700+
sigmax = SIGRTMAX;
701+
}
702+
#endif
703+
#else
704+
// max signal on mac is SIGUSR2 (31), no real time signals.
705+
static int sigmax = NSIG - 1;
706+
#endif
707+
708+
if (signo < 1 || signo > sigmax) {
709+
zend_argument_value_error(1, "must be between 1 and %d", sigmax);
697710
RETURN_THROWS();
698711
}
699712

0 commit comments

Comments
 (0)