Allow SA_RESTART for SIGALRM
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 14 Jan 2019 12:04:37 +0000 (13:04 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 2 Oct 2019 08:09:17 +0000 (10:09 +0200)
If no explicit restart_syscalls is passed, default to
restart_syscalls=0 for SIGALRM only, to reduce BC impact.

NEWS
UPGRADING
ext/pcntl/pcntl.c
ext/pcntl/php_signal.c

diff --git a/NEWS b/NEWS
index a7f668fa8c94d0549408a1ccd52515740fce3fca..23890c7d7a5e77e45b51564ba2ea8543f9738044 100644 (file)
--- 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)
index 7f69dc4b4dd16a496931bdc891edd500428098bc..79a69df045d214a2fe83c32fac4dcf63707ae01e 100644 (file)
--- 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
index 300de1e7d48290038f6f05735f8b3b35bb34c57b..cd85080c9b7bec6d0902af067c49e765e0a1d48f 100644 (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) {
index da7881b255556a4caf5147217c448ed74d2bf99e..93a42f45d17ecde7dae29b1259e3fa0a0e70cc64 100644 (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