Skip to content

Commit e98e1f9

Browse files
committed
Allow SA_RESTART for SIGALRM
If no explicit restart_syscalls is passed, default to restart_syscalls=0 for SIGALRM only, to reduce BC impact.
1 parent 6462c19 commit e98e1f9

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.4.0RC4
44

5+
- Pcntl:
6+
. Fixed bug #77335 (PHP is preventing SIGALRM from specifying SA_RESTART).
7+
(Nikita)
8+
59
- SimpleXML:
610
. Fixed bug #75245 (Don't set content of elements with only whitespaces).
711
(eriklundin)

UPGRADING

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ PHP 7.4 UPGRADE NOTES
8282
function does not throw, so explicitly checking it is not necessary.
8383
RFC: http://php.net/manual/de/function.openssl-random-pseudo-bytes.php
8484

85+
- Pcntl:
86+
. The $restart_syscalls flag for pcntl_signal() will now be respected for
87+
SIGALARM. Previously it was hardcoded to false. To reduce the backwards
88+
compatibility impact, the default for SIGALARM will remain false however.
89+
8590
- PCRE:
8691
. When PREG_UNMATCHED_AS_NULL mode is used, trailing unmatched capturing
8792
groups will now also be set to null (or [null, -1] if offset capture is

ext/pcntl/pcntl.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,9 @@ PHP_FUNCTION(pcntl_signal)
10571057
zval *handle;
10581058
zend_long signo;
10591059
zend_bool restart_syscalls = 1;
1060+
zend_bool restart_syscalls_is_null = 1;
10601061

1061-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz|b", &signo, &handle, &restart_syscalls) == FAILURE) {
1062+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz|b!", &signo, &handle, &restart_syscalls, &restart_syscalls_is_null) == FAILURE) {
10621063
return;
10631064
}
10641065

@@ -1080,6 +1081,13 @@ PHP_FUNCTION(pcntl_signal)
10801081
}
10811082
}
10821083

1084+
/* If restart_syscalls was not explicitly specified and the signal is SIGALRM, then default
1085+
* restart_syscalls to false. PHP used to enforce that restart_syscalls is false for SIGALRM,
1086+
* so we keep this differing default to reduce the degree of BC breakage. */
1087+
if (restart_syscalls_is_null && signo == SIGALRM) {
1088+
restart_syscalls = 0;
1089+
}
1090+
10831091
/* Special long value case for SIG_DFL and SIG_IGN */
10841092
if (Z_TYPE_P(handle) == IS_LONG) {
10851093
if (Z_LVAL_P(handle) != (zend_long) SIG_DFL && Z_LVAL_P(handle) != (zend_long) SIG_IGN) {

ext/pcntl/php_signal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all)
4141
#ifdef HAVE_STRUCT_SIGINFO_T
4242
act.sa_flags |= SA_SIGINFO;
4343
#endif
44-
if (signo == SIGALRM || (! restart)) {
44+
if (!restart) {
4545
#ifdef SA_INTERRUPT
4646
act.sa_flags |= SA_INTERRUPT; /* SunOS */
4747
#endif

0 commit comments

Comments
 (0)