From e98e1f92c98b7c8910c55835d8f67d0d9230cc8b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 14 Jan 2019 13:04:37 +0100 Subject: [PATCH] Allow SA_RESTART for SIGALRM If no explicit restart_syscalls is passed, default to restart_syscalls=0 for SIGALRM only, to reduce BC impact. --- NEWS | 4 ++++ UPGRADING | 5 +++++ ext/pcntl/pcntl.c | 10 +++++++++- ext/pcntl/php_signal.c | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index a7f668fa8c94d..23890c7d7a5e7 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 7.4.0RC4 +- Pcntl: + . Fixed bug #77335 (PHP is preventing SIGALRM from specifying SA_RESTART). + (Nikita) + - SimpleXML: . Fixed bug #75245 (Don't set content of elements with only whitespaces). (eriklundin) diff --git a/UPGRADING b/UPGRADING index 7f69dc4b4dd16..79a69df045d21 100644 --- a/UPGRADING +++ b/UPGRADING @@ -82,6 +82,11 @@ PHP 7.4 UPGRADE NOTES function does not throw, so explicitly checking it is not necessary. RFC: http://php.net/manual/de/function.openssl-random-pseudo-bytes.php +- Pcntl: + . The $restart_syscalls flag for pcntl_signal() will now be respected for + SIGALARM. Previously it was hardcoded to false. To reduce the backwards + compatibility impact, the default for SIGALARM will remain false however. + - PCRE: . When PREG_UNMATCHED_AS_NULL mode is used, trailing unmatched capturing groups will now also be set to null (or [null, -1] if offset capture is diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 300de1e7d4829..cd85080c9b7be 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -1057,8 +1057,9 @@ PHP_FUNCTION(pcntl_signal) zval *handle; zend_long signo; zend_bool restart_syscalls = 1; + zend_bool restart_syscalls_is_null = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz|b", &signo, &handle, &restart_syscalls) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz|b!", &signo, &handle, &restart_syscalls, &restart_syscalls_is_null) == FAILURE) { return; } @@ -1080,6 +1081,13 @@ PHP_FUNCTION(pcntl_signal) } } + /* If restart_syscalls was not explicitly specified and the signal is SIGALRM, then default + * restart_syscalls to false. PHP used to enforce that restart_syscalls is false for SIGALRM, + * so we keep this differing default to reduce the degree of BC breakage. */ + if (restart_syscalls_is_null && signo == SIGALRM) { + restart_syscalls = 0; + } + /* Special long value case for SIG_DFL and SIG_IGN */ if (Z_TYPE_P(handle) == IS_LONG) { if (Z_LVAL_P(handle) != (zend_long) SIG_DFL && Z_LVAL_P(handle) != (zend_long) SIG_IGN) { diff --git a/ext/pcntl/php_signal.c b/ext/pcntl/php_signal.c index da7881b255556..93a42f45d17ec 100644 --- a/ext/pcntl/php_signal.c +++ b/ext/pcntl/php_signal.c @@ -41,7 +41,7 @@ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all) #ifdef HAVE_STRUCT_SIGINFO_T act.sa_flags |= SA_SIGINFO; #endif - if (signo == SIGALRM || (! restart)) { + if (!restart) { #ifdef SA_INTERRUPT act.sa_flags |= SA_INTERRUPT; /* SunOS */ #endif