[php-src] master: ext/pcntl pcntl_signal_get_handler update.
| From: | David Carlier | Date: | Sun, 07 Apr 2024 12:26:09 +0000 |
| Subject: | [php-src] master: ext/pcntl pcntl_signal_get_handler update. | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-127963@lists.php.net to get a copy of this message | ||
Author: David Carlier (devnexen)
Date: 2024-04-07T13:25:45+01:00
Commit: https://github.com/php/php-src/commit/01817e99ab4da5938503eef952a2e933c4695eaf
Raw diff: https://github.com/php/php-src/commit/01817e99ab4da5938503eef952a2e933c4695eaf.diff
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
Changed paths:
M NEWS
M ext/pcntl/pcntl.c
Diff:
diff --git a/NEWS b/NEWS
index 465764628b08..3c994abb3779 100644
--- a/NEWS
+++ b/NEWS
@@ -125,6 +125,8 @@ PHP NEWS
- PCNTL:
. Added pcntl_setns for Linux. (David Carlier)
. Added pcntl_getaffinity/pcntl_setaffinity. (David Carlier)
+ . Updated pcntl_get_signal_handler signal id upper limit to be
+ more in line with platforms limits. (David Carlier)
- PCRE:
. Upgrade bundled pcre2lib to version 10.43. (nielsdos)
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index fcd2315e8c24..891619afc60a 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.
+ 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();
}