diff --git a/ext/pcntl/config.m4 b/ext/pcntl/config.m4 index 073148a0a1d48..498cc9b4a6033 100644 --- a/ext/pcntl/config.m4 +++ b/ext/pcntl/config.m4 @@ -28,7 +28,5 @@ int main(void) { AC_MSG_RESULT([no, cross-compiling]) ]) - AC_CHECK_TYPE([siginfo_t],[PCNTL_CFLAGS="-DHAVE_STRUCT_SIGINFO_T"],,[#include ]) - PHP_NEW_EXTENSION(pcntl, pcntl.c php_signal.c, $ext_shared, cli, $PCNTL_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) fi diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 1c09253f8dfd5..6f67508a67529 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -104,12 +104,8 @@ ZEND_GET_MODULE(pcntl) static void (*orig_interrupt_function)(zend_execute_data *execute_data); -#ifdef HAVE_STRUCT_SIGINFO_T static void pcntl_signal_handler(int, siginfo_t*, void*); static void pcntl_siginfo_to_zval(int, siginfo_t*, zval*); -#else -static void pcntl_signal_handler(int); -#endif static void pcntl_signal_dispatch(void); static void pcntl_signal_dispatch_tick_function(int dummy_int, void *dummy_pointer); static void pcntl_interrupt_function(zend_execute_data *execute_data); @@ -166,7 +162,7 @@ PHP_RSHUTDOWN_FUNCTION(pcntl) /* Reset all signals to their default disposition */ ZEND_HASH_FOREACH_NUM_KEY_VAL(&PCNTL_G(php_signal_table), signo, handle) { if (Z_TYPE_P(handle) != IS_LONG || Z_LVAL_P(handle) != (zend_long)SIG_DFL) { - php_signal(signo, (Sigfunc *)(zend_long)SIG_DFL, 0); + php_signal(signo, (Sigfunc *)(zend_long)SIG_DFL, false); } } ZEND_HASH_FOREACH_END(); @@ -662,7 +658,7 @@ PHP_FUNCTION(pcntl_signal) zend_argument_value_error(2, "must be either SIG_DFL or SIG_IGN when an integer value is given"); RETURN_THROWS(); } - if (php_signal(signo, (Sigfunc *) Z_LVAL_P(handle), (int) restart_syscalls) == (void *)SIG_ERR) { + if (php_signal(signo, (Sigfunc *) Z_LVAL_P(handle), restart_syscalls) == (void *)SIG_ERR) { PCNTL_G(last_error) = errno; php_error_docref(NULL, E_WARNING, "Error assigning signal"); RETURN_FALSE; @@ -682,7 +678,7 @@ PHP_FUNCTION(pcntl_signal) handle = zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle); Z_TRY_ADDREF_P(handle); - if (php_signal4(signo, pcntl_signal_handler, (int) restart_syscalls, 1) == (void *)SIG_ERR) { + if (php_signal4(signo, pcntl_signal_handler, restart_syscalls, true) == (void *)SIG_ERR) { PCNTL_G(last_error) = errno; php_error_docref(NULL, E_WARNING, "Error assigning signal"); RETURN_FALSE; @@ -841,8 +837,7 @@ PHP_FUNCTION(pcntl_sigprocmask) /* }}} */ #endif -#ifdef HAVE_STRUCT_SIGINFO_T -# ifdef HAVE_SIGWAITINFO +#ifdef HAVE_SIGWAITINFO /* {{{ Synchronously wait for queued signals */ PHP_FUNCTION(pcntl_sigwaitinfo) @@ -884,8 +879,9 @@ PHP_FUNCTION(pcntl_sigwaitinfo) RETURN_LONG(signal_no); } /* }}} */ -# endif -# ifdef HAVE_SIGTIMEDWAIT +#endif + +#ifdef HAVE_SIGTIMEDWAIT /* {{{ Wait for queued signals */ PHP_FUNCTION(pcntl_sigtimedwait) { @@ -947,7 +943,7 @@ PHP_FUNCTION(pcntl_sigtimedwait) RETURN_LONG(signal_no); } /* }}} */ -# endif +#endif static void pcntl_siginfo_to_zval(int signo, siginfo_t *siginfo, zval *user_siginfo) /* {{{ */ { @@ -1003,7 +999,6 @@ static void pcntl_siginfo_to_zval(int signo, siginfo_t *siginfo, zval *user_sigi } } /* }}} */ -#endif #ifdef HAVE_GETPRIORITY /* {{{ Get the priority of any process */ @@ -1145,11 +1140,7 @@ PHP_FUNCTION(pcntl_strerror) /* }}} */ /* Our custom signal handler that calls the appropriate php_function */ -#ifdef HAVE_STRUCT_SIGINFO_T static void pcntl_signal_handler(int signo, siginfo_t *siginfo, void *context) -#else -static void pcntl_signal_handler(int signo) -#endif { struct php_pcntl_pending_signal *psig = PCNTL_G(spares); if (!psig) { @@ -1161,9 +1152,7 @@ static void pcntl_signal_handler(int signo) psig->signo = signo; psig->next = NULL; -#ifdef HAVE_STRUCT_SIGINFO_T psig->siginfo = *siginfo; -#endif /* the head check is important, as the tick handler cannot atomically clear both * the head and tail */ @@ -1215,20 +1204,14 @@ void pcntl_signal_dispatch(void) if (Z_TYPE_P(handle) != IS_LONG) { ZVAL_NULL(&retval); ZVAL_LONG(¶ms[0], queue->signo); -#ifdef HAVE_STRUCT_SIGINFO_T array_init(¶ms[1]); pcntl_siginfo_to_zval(queue->signo, &queue->siginfo, ¶ms[1]); -#else - ZVAL_NULL(¶ms[1]); -#endif /* Call php signal handler - Note that we do not report errors, and we ignore the return value */ /* FIXME: this is probably broken when multiple signals are handled in this while loop (retval) */ call_user_function(NULL, NULL, handle, &retval, 2, params); zval_ptr_dtor(&retval); -#ifdef HAVE_STRUCT_SIGINFO_T zval_ptr_dtor(¶ms[1]); -#endif } } diff --git a/ext/pcntl/pcntl.stub.php b/ext/pcntl/pcntl.stub.php index cf1b5a4cced5f..373f35295f768 100644 --- a/ext/pcntl/pcntl.stub.php +++ b/ext/pcntl/pcntl.stub.php @@ -932,7 +932,6 @@ function pcntl_signal_dispatch(): bool {} function pcntl_sigprocmask(int $mode, array $signals, &$old_signals = null): bool {} #endif -#ifdef HAVE_STRUCT_SIGINFO_T #if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) /** @param array $info */ function pcntl_sigwaitinfo(array $signals, &$info = []): int|false {} @@ -940,7 +939,6 @@ function pcntl_sigwaitinfo(array $signals, &$info = []): int|false {} /** @param array $info */ function pcntl_sigtimedwait(array $signals, &$info = [], int $seconds = 0, int $nanoseconds = 0): int|false {} #endif -#endif function pcntl_wifexited(int $status): bool {} diff --git a/ext/pcntl/pcntl_arginfo.h b/ext/pcntl/pcntl_arginfo.h index 734fb3976e0af..34cdd9a46e136 100644 --- a/ext/pcntl/pcntl_arginfo.h +++ b/ext/pcntl/pcntl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 3e15bebb568e6e2031acbd932d6eefbd23984c83 */ + * Stub hash: a1f98440ed557fafc97ed685df0adc989fda9a79 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_fork, 0, 0, IS_LONG, 0) ZEND_END_ARG_INFO() @@ -38,14 +38,14 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_sigprocmask, 0, 2, _IS_BOO ZEND_END_ARG_INFO() #endif -#if defined(HAVE_STRUCT_SIGINFO_T) && (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) +#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pcntl_sigwaitinfo, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, signals, IS_ARRAY, 0) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, info, "[]") ZEND_END_ARG_INFO() #endif -#if defined(HAVE_STRUCT_SIGINFO_T) && (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) +#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pcntl_sigtimedwait, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, signals, IS_ARRAY, 0) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, info, "[]") @@ -177,10 +177,10 @@ ZEND_FUNCTION(pcntl_signal_dispatch); #if defined(HAVE_SIGPROCMASK) ZEND_FUNCTION(pcntl_sigprocmask); #endif -#if defined(HAVE_STRUCT_SIGINFO_T) && (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) +#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) ZEND_FUNCTION(pcntl_sigwaitinfo); #endif -#if defined(HAVE_STRUCT_SIGINFO_T) && (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) +#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) ZEND_FUNCTION(pcntl_sigtimedwait); #endif ZEND_FUNCTION(pcntl_wifexited); @@ -241,10 +241,10 @@ static const zend_function_entry ext_functions[] = { #if defined(HAVE_SIGPROCMASK) ZEND_FE(pcntl_sigprocmask, arginfo_pcntl_sigprocmask) #endif -#if defined(HAVE_STRUCT_SIGINFO_T) && (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) +#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) ZEND_FE(pcntl_sigwaitinfo, arginfo_pcntl_sigwaitinfo) #endif -#if defined(HAVE_STRUCT_SIGINFO_T) && (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) +#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) ZEND_FE(pcntl_sigtimedwait, arginfo_pcntl_sigtimedwait) #endif ZEND_FE(pcntl_wifexited, arginfo_pcntl_wifexited) diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h index d34771062be7b..ac4d02a2d6efc 100644 --- a/ext/pcntl/php_pcntl.h +++ b/ext/pcntl/php_pcntl.h @@ -36,9 +36,7 @@ PHP_MINFO_FUNCTION(pcntl); struct php_pcntl_pending_signal { struct php_pcntl_pending_signal *next; zend_long signo; -#ifdef HAVE_STRUCT_SIGINFO_T siginfo_t siginfo; -#endif }; ZEND_BEGIN_MODULE_GLOBALS(pcntl) diff --git a/ext/pcntl/php_signal.c b/ext/pcntl/php_signal.c index 14c169310e601..7f27ac33e45d4 100644 --- a/ext/pcntl/php_signal.c +++ b/ext/pcntl/php_signal.c @@ -21,24 +21,18 @@ /* php_signal using sigaction is derived from Advanced Programming * in the Unix Environment by W. Richard Stevens p 298. */ -Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all) +Sigfunc *php_signal4(int signo, Sigfunc *func, bool restart, bool mask_all) { struct sigaction act,oact; -#ifdef HAVE_STRUCT_SIGINFO_T act.sa_sigaction = func; -#else - act.sa_handler = func; -#endif if (mask_all) { sigfillset(&act.sa_mask); } else { sigemptyset(&act.sa_mask); } act.sa_flags = SA_ONSTACK; -#ifdef HAVE_STRUCT_SIGINFO_T act.sa_flags |= SA_SIGINFO; -#endif if (!restart) { #ifdef SA_INTERRUPT act.sa_flags |= SA_INTERRUPT; /* SunOS */ @@ -50,14 +44,10 @@ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all) } zend_sigaction(signo, &act, &oact); -#ifdef HAVE_STRUCT_SIGINFO_T return oact.sa_sigaction; -#else - return oact.sa_handler; -#endif } -Sigfunc *php_signal(int signo, Sigfunc *func, int restart) +Sigfunc *php_signal(int signo, Sigfunc *func, bool restart) { - return php_signal4(signo, func, restart, 0); + return php_signal4(signo, func, restart, false); } diff --git a/ext/pcntl/php_signal.h b/ext/pcntl/php_signal.h index 256898e70acbc..44cbd68999f10 100644 --- a/ext/pcntl/php_signal.h +++ b/ext/pcntl/php_signal.h @@ -18,12 +18,9 @@ #ifndef PHP_SIGNAL_H #define PHP_SIGNAL_H -#ifdef HAVE_STRUCT_SIGINFO_T typedef void Sigfunc(int, siginfo_t*, void*); -#else -typedef void Sigfunc(int); -#endif -Sigfunc *php_signal(int signo, Sigfunc *func, int restart); -Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all); + +Sigfunc *php_signal(int signo, Sigfunc *func, bool restart); +Sigfunc *php_signal4(int signo, Sigfunc *func, bool restart, bool mask_all); #endif