Skip to content

Commit

Permalink
Allow SA_RESTART for SIGALRM
Browse files Browse the repository at this point in the history
If no explicit restart_syscalls is passed, default to
restart_syscalls=0 for SIGALRM only, to reduce BC impact.
  • Loading branch information
nikic committed Oct 2, 2019
1 parent 6462c19 commit e98e1f9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion ext/pcntl/pcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion ext/pcntl/php_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e98e1f9

Please sign in to comment.