Allow SA_RESTART for SIGALRM

If no explicit restart_syscalls is passed, default to
restart_syscalls=0 for SIGALRM only, to reduce BC impact.
This commit is contained in:
Nikita Popov 2019-01-14 13:04:37 +01:00
parent 6462c19689
commit e98e1f92c9
4 changed files with 19 additions and 2 deletions

4
NEWS
View file

@ -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)

View file

@ -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

View file

@ -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) {

View file

@ -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