mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Work around incorrect NSIG on FreeBSD
This commit is contained in:
parent
d3e8ae1243
commit
485a42f495
@ -47,11 +47,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef NSIG
|
||||
# ifdef SIGRTMAX
|
||||
# define NSIG (SIGRTMAX + 1)
|
||||
# else
|
||||
# define NSIG 32
|
||||
# endif
|
||||
# define NSIG 32
|
||||
#endif
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(pcntl)
|
||||
@ -430,6 +426,14 @@ PHP_RINIT_FUNCTION(pcntl)
|
||||
PCNTL_G(head) = PCNTL_G(tail) = PCNTL_G(spares) = NULL;
|
||||
PCNTL_G(async_signals) = 0;
|
||||
PCNTL_G(last_error) = 0;
|
||||
PCNTL_G(num_signals) = NSIG;
|
||||
#ifdef SIGRTMAX
|
||||
/* At least FreeBSD reports an incorrecrt NSIG that does not include realtime signals.
|
||||
* As SIGRTMAX may be a dynamic value, adjust the value in INIT. */
|
||||
if (NSIG < SIGRTMAX + 1) {
|
||||
PCNTL_G(num_signals) = SIGRTMAX + 1;
|
||||
}
|
||||
#endif
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@ -900,8 +904,8 @@ PHP_FUNCTION(pcntl_signal)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
if (signo >= NSIG) {
|
||||
zend_argument_value_error(1, "must be less than %d", NSIG);
|
||||
if (signo >= PCNTL_G(num_signals)) {
|
||||
zend_argument_value_error(1, "must be less than %d", PCNTL_G(num_signals));
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
@ -909,7 +913,7 @@ PHP_FUNCTION(pcntl_signal)
|
||||
/* since calling malloc() from within a signal handler is not portable,
|
||||
* pre-allocate a few records for recording signals */
|
||||
int i;
|
||||
for (i = 0; i < NSIG; i++) {
|
||||
for (i = 0; i < PCNTL_G(num_signals); i++) {
|
||||
struct php_pcntl_pending_signal *psig;
|
||||
|
||||
psig = emalloc(sizeof(*psig));
|
||||
@ -1037,7 +1041,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
for (signo = 1; signo < NSIG; ++signo) {
|
||||
for (signo = 1; signo < PCNTL_G(num_signals); ++signo) {
|
||||
if (sigismember(&oldset, signo) != 1) {
|
||||
continue;
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ ZEND_BEGIN_MODULE_GLOBALS(pcntl)
|
||||
int last_error;
|
||||
volatile char pending_signals;
|
||||
bool async_signals;
|
||||
unsigned num_signals;
|
||||
ZEND_END_MODULE_GLOBALS(pcntl)
|
||||
|
||||
#if defined(ZTS) && defined(COMPILE_DL_PCNTL)
|
||||
|
Loading…
Reference in New Issue
Block a user