From 3dc007edc5feb50f823c227029fe9a54062dce3b Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 7 Apr 2024 08:43:23 +0100 Subject: [PATCH 1/2] ext/pcntl pcntl_signal_get_handler update. The situation varies from platform to another, thus taking in account the complexity of it. --- ext/pcntl/pcntl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index fcd2315e8c24..a745349498cd 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -692,8 +692,17 @@ PHP_FUNCTION(pcntl_signal_get_handler) Z_PARAM_LONG(signo) ZEND_PARSE_PARAMETERS_END(); - if (signo < 1 || signo > 32) { - zend_argument_value_error(1, "must be between 1 and 32"); + // note: max signal on mac is SIGUSR2 (31), no real time signals. + static int sigmax = NSIG - 1; +#if defined(SIGRTMAX) + // oddily enough, NSIG on freebsd reports only 32 whereas SIGRTMIN starts at 65. + if (sigmax < SIGRTMAX) { + sigmax = SIGRTMAX; + } +#endif + + if (signo < 1 || signo > sigmax) { + zend_argument_value_error(1, "must be between 1 and %d", sigmax); RETURN_THROWS(); } From ecb847d39fb91697e1f65c522d148f495bda5d3f Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 7 Apr 2024 13:00:06 +0100 Subject: [PATCH 2/2] remove static qualifier for the var holder --- ext/pcntl/pcntl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index a745349498cd..891619afc60a 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -693,7 +693,7 @@ PHP_FUNCTION(pcntl_signal_get_handler) ZEND_PARSE_PARAMETERS_END(); // note: max signal on mac is SIGUSR2 (31), no real time signals. - static int sigmax = NSIG - 1; + int sigmax = NSIG - 1; #if defined(SIGRTMAX) // oddily enough, NSIG on freebsd reports only 32 whereas SIGRTMIN starts at 65. if (sigmax < SIGRTMAX) {