From 459f0e58792d7ea4030822a5ed3d7c1ea7f5b6b1 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 14 Jan 2019 13:04:37 +0100 Subject: [PATCH] Allow SA_RESTART for SIGALRM If no explicit restart_syscalls is passed, default to restart_syscalls=0 for SIGALRM only, to reduce BC impact. --- ext/pcntl/pcntl.c | 10 +++++++++- ext/pcntl/php_signal.c | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index cf53edc7f699c..fc45757d46f14 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -999,8 +999,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; } @@ -1022,6 +1023,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 32a6c55c93bc1..30b753409d128 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