Skip to content

Allow SA_RESTART for SIGALRM #3742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ext/pcntl/pcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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) {
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