Skip to content

Commit 01817e9

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. Close GH-13902
1 parent a22a872 commit 01817e9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ PHP NEWS
125125
- PCNTL:
126126
. Added pcntl_setns for Linux. (David Carlier)
127127
. Added pcntl_getaffinity/pcntl_setaffinity. (David Carlier)
128+
. Updated pcntl_get_signal_handler signal id upper limit to be
129+
more in line with platforms limits. (David Carlier)
128130

129131
- PCRE:
130132
. Upgrade bundled pcre2lib to version 10.43. (nielsdos)

ext/pcntl/pcntl.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,17 @@ 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+
// note: max signal on mac is SIGUSR2 (31), no real time signals.
696+
int sigmax = NSIG - 1;
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+
704+
if (signo < 1 || signo > sigmax) {
705+
zend_argument_value_error(1, "must be between 1 and %d", sigmax);
697706
RETURN_THROWS();
698707
}
699708

0 commit comments

Comments
 (0)