summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-01-14 13:04:37 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-10-02 10:09:17 +0200
commite98e1f92c98b7c8910c55835d8f67d0d9230cc8b (patch)
tree38bbd57505dfb421d2bf2745d3a772512026aea3 /ext
parent6462c196897b8c5ccf606b8af8de790b77799de6 (diff)
downloadphp-git-e98e1f92c98b7c8910c55835d8f67d0d9230cc8b.tar.gz
Allow SA_RESTART for SIGALRM
If no explicit restart_syscalls is passed, default to restart_syscalls=0 for SIGALRM only, to reduce BC impact.
Diffstat (limited to 'ext')
-rw-r--r--ext/pcntl/pcntl.c10
-rw-r--r--ext/pcntl/php_signal.c2
2 files changed, 10 insertions, 2 deletions
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 300de1e7d4..cd85080c9b 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 da7881b255..93a42f45d1 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