diff --git a/UPGRADING b/UPGRADING
index 9dbcd594a29a..386f5a79a34a 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -22,6 +22,11 @@ PHP 8.7 UPGRADE NOTES
- Core:
. Block declaration support for the encoding declare has been removed as it
did not function properly.
+ . Zend Signals has been removed, along with the --disable-zend-signals
+ configure option and the "Zend Signal Handling" phpinfo() entry. Signals
+ are no longer deferred while the engine runs, including while OPcache
+ writes to shared memory. pcntl_signal() handlers are replaced at request
+ shutdown by the handler installed before the request, instead of SIG_DFL.
- Curl:
. curl_multi_exec() now throws a TypeError when $still_running cannot be
@@ -184,6 +189,9 @@ PHP 8.7 UPGRADE NOTES
11. Changes to INI File Handling
========================================
+- Core:
+ . The zend.signal_check INI setting has been removed.
+
- Opcache:
. opcache.max_accelerated_files now defaults to 16229 (previously 10000),
accepts values up to 1048793 (previously 1000000), and logs a warning for
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index a2f9bc7f01c9..bb1f18a7d3ff 100644
--- a/UPGRADING.INTERNALS
+++ b/UPGRADING.INTERNALS
@@ -15,6 +15,13 @@ PHP 8.7 INTERNALS UPGRADE NOTES
========================
- Breaking changes:
+ . Zend Signals has been removed, along with Zend/zend_signal.h. ZEND_SIGNALS,
+ SIGG(), zend_signal_globals_t, HANDLE_BLOCK_INTERRUPTIONS(),
+ HANDLE_UNBLOCK_INTERRUPTIONS(), ZEND_SIGNAL_BLOCK_INTERRUPTIONS(),
+ ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS(), zend_signal_startup(),
+ zend_signal_init(), zend_signal_activate(), zend_signal_deactivate(),
+ zend_signal() and zend_sigaction() no longer exist. Use signal() and
+ sigaction() directly.
. Added zend_module_entry.child_init_func, an optional void callback invoked
by php_child_init() in the child process after core child initialization.
It runs in module dependency order for started modules and may run before a
@@ -116,6 +123,7 @@ PHP 8.7 INTERNALS UPGRADE NOTES
- Unix build system changes:
. Autoconf minimum required version upgraded to 2.71.
+ . The --disable-zend-signals configure option has been removed.
========================
3. Module changes
diff --git a/Zend/Zend.m4 b/Zend/Zend.m4
index 437aff154074..2b9f32b5b6aa 100644
--- a/Zend/Zend.m4
+++ b/Zend/Zend.m4
@@ -216,7 +216,6 @@ AX_CHECK_COMPILE_FLAG([-fno-common],
[CFLAGS="-fno-common $CFLAGS"])
ZEND_CHECK_ALIGNMENT
-ZEND_CHECK_SIGNALS
ZEND_CHECK_MAX_EXECUTION_TIMERS
])
@@ -435,28 +434,6 @@ AS_VAR_IF([php_cv_align_mm], [failed],
])
])
-dnl
-dnl ZEND_CHECK_SIGNALS
-dnl
-dnl Check whether to enable Zend signal handling if supported by the system.
-dnl
-AC_DEFUN([ZEND_CHECK_SIGNALS], [dnl
-AC_ARG_ENABLE([zend-signals],
- [AS_HELP_STRING([--disable-zend-signals],
- [Disable Zend signal handling])],
- [ZEND_SIGNALS=$enableval],
- [ZEND_SIGNALS=yes])
-
-AC_CHECK_FUNCS([sigaction],, [ZEND_SIGNALS=no])
-AS_VAR_IF([ZEND_SIGNALS], [yes],
- [AC_DEFINE([ZEND_SIGNALS], [1],
- [Define to 1 if Zend signal handling is supported and enabled.])
- AS_VAR_APPEND([CFLAGS], [" -DZEND_SIGNALS"])])
-
-AC_MSG_CHECKING([whether to enable Zend signal handling])
-AC_MSG_RESULT([$ZEND_SIGNALS])
-])
-
dnl
dnl ZEND_CHECK_MAX_EXECUTION_TIMERS
dnl
diff --git a/Zend/zend.c b/Zend/zend.c
index 560a365318de..bb9141e722bc 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -257,12 +257,6 @@ static ZEND_INI_MH(OnUpdateFiberStackSize) /* {{{ */
}
/* }}} */
-#if ZEND_DEBUG
-# define SIGNAL_CHECK_DEFAULT "1"
-#else
-# define SIGNAL_CHECK_DEFAULT "0"
-#endif
-
ZEND_INI_BEGIN()
ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
STD_ZEND_INI_BOOLEAN("fatal_error_backtraces", "1", ZEND_INI_ALL, OnUpdateBool, fatal_error_backtrace_on, zend_executor_globals, executor_globals)
@@ -271,9 +265,6 @@ ZEND_INI_BEGIN()
STD_ZEND_INI_BOOLEAN("zend.multibyte", "0", ZEND_INI_PERDIR, OnUpdateBool, multibyte, zend_compiler_globals, compiler_globals)
ZEND_INI_ENTRY("zend.script_encoding", NULL, ZEND_INI_ALL, OnUpdateScriptEncoding)
STD_ZEND_INI_BOOLEAN("zend.detect_unicode", "1", ZEND_INI_ALL, OnUpdateBool, detect_unicode, zend_compiler_globals, compiler_globals)
-#ifdef ZEND_SIGNALS
- STD_ZEND_INI_BOOLEAN("zend.signal_check", SIGNAL_CHECK_DEFAULT, ZEND_INI_SYSTEM, OnUpdateBool, check, zend_signal_globals_t, zend_signal_globals)
-#endif
STD_ZEND_INI_BOOLEAN("zend.exception_ignore_args", "0", ZEND_INI_ALL, OnUpdateBool, exception_ignore_args, zend_executor_globals, executor_globals)
STD_ZEND_INI_ENTRY("zend.exception_string_param_max_len", "15", ZEND_INI_ALL, OnSetExceptionStringParamMaxLen, exception_string_param_max_len, zend_executor_globals, executor_globals)
STD_ZEND_INI_ENTRY("fiber.stack_size", NULL, ZEND_INI_ALL, OnUpdateFiberStackSize, fiber_stack_size, zend_executor_globals, executor_globals)
diff --git a/Zend/zend.h b/Zend/zend.h
index 29863fba687c..1e969aa85d12 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -37,14 +37,10 @@
#include "zend_stream.h"
#include "zend_smart_str_public.h"
#include "zend_smart_string_public.h"
-#include "zend_signal.h"
#include "zend_max_execution_timer.h"
#define zend_sprintf sprintf
-#define HANDLE_BLOCK_INTERRUPTIONS() ZEND_SIGNAL_BLOCK_INTERRUPTIONS()
-#define HANDLE_UNBLOCK_INTERRUPTIONS() ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
-
#define INTERNAL_FUNCTION_PARAMETERS zend_execute_data *execute_data, zval *return_value
#define INTERNAL_FUNCTION_PARAM_PASSTHRU execute_data, return_value
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index a56bc53725bd..7c070f2cfdbb 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -1694,24 +1694,20 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */
# endif
if (reset_signals) {
-# ifdef ZEND_SIGNALS
- zend_signal(signo, zend_timeout_handler);
-# else
sigset_t sigset;
-# ifdef HAVE_SIGACTION
+# ifdef HAVE_SIGACTION
struct sigaction act;
act.sa_handler = zend_timeout_handler;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_ONSTACK | SA_RESETHAND | SA_NODEFER;
sigaction(signo, &act, NULL);
-# else
+# else
signal(signo, zend_timeout_handler);
-# endif /* HAVE_SIGACTION */
+# endif /* HAVE_SIGACTION */
sigemptyset(&sigset);
sigaddset(&sigset, signo);
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
-# endif /* ZEND_SIGNALS */
}
}
#endif /* HAVE_SETITIMER */
diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c
deleted file mode 100644
index 095650a535bb..000000000000
--- a/Zend/zend_signal.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | Zend Signal Handling |
- +----------------------------------------------------------------------+
- | Copyright © The PHP Group and Contributors. |
- +----------------------------------------------------------------------+
- | This source file is subject to the Modified BSD License that is |
- | bundled with this package in the file LICENSE, and is available |
- | through the World Wide Web at . |
- | |
- | SPDX-License-Identifier: BSD-3-Clause |
- +----------------------------------------------------------------------+
- | Authors: Lucas Nealan |
- | Arnaud Le Blanc |
- +----------------------------------------------------------------------+
-
- This software was contributed to PHP by Facebook Inc. in 2008.
-
- Future revisions and derivatives of this source code must acknowledge
- Facebook Inc. as the original contributor of this module by leaving
- this note intact in the source code.
-
- All other licensing and usage conditions are those of the PHP Group and
- Contributors.
- */
-
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-#endif
-#include
-
-#include "zend.h"
-#include "zend_globals.h"
-#include
-
-#ifdef HAVE_UNISTD_H
-#include
-#endif
-
-#ifdef ZEND_SIGNALS
-
-#include "zend_signal.h"
-
-#ifdef ZTS
-ZEND_API int zend_signal_globals_id;
-ZEND_TLS_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_signal_globals_t zend_signal_globals;
-static void *zend_signal_globals_tls_addr(void) { return &zend_signal_globals; }
-#else
-ZEND_API zend_signal_globals_t zend_signal_globals;
-#endif /* not ZTS */
-
-#define SIGNAL_BEGIN_CRITICAL() \
- sigset_t oldmask; \
- zend_sigprocmask(SIG_BLOCK, &global_sigmask, &oldmask);
-#define SIGNAL_END_CRITICAL() \
- zend_sigprocmask(SIG_SETMASK, &oldmask, NULL);
-
-#ifdef ZTS
-# define zend_sigprocmask(signo, set, oldset) tsrm_sigmask((signo), (set), (oldset))
-#else
-# define zend_sigprocmask(signo, set, oldset) sigprocmask((signo), (set), (oldset))
-#endif
-
-static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context);
-static zend_result zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*));
-
-#if defined(__CYGWIN__) || defined(__PASE__)
-/* Matches zend_execute_API.c; these platforms don't support ITIMER_PROF. */
-#define TIMEOUT_SIG SIGALRM
-#else
-#define TIMEOUT_SIG SIGPROF
-#endif
-
-static const int zend_sigs[] = { TIMEOUT_SIG, SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2 };
-
-#define SA_FLAGS_MASK ~(SA_NODEFER | SA_RESETHAND)
-
-/* True globals, written only at process startup */
-static zend_signal_entry_t global_orig_handlers[NSIG];
-static sigset_t global_sigmask;
-
-/* {{{ zend_signal_handler_defer
- * Blocks signals if in critical section */
-static void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
-{
- int errno_save = errno;
- zend_signal_queue_t *queue, *qtmp;
-
-#ifdef ZTS
- /* A signal could hit after TSRM shutdown, in this case globals are already freed.
- * Or it could be delivered to a thread that didn't execute PHP yet.
- * In the latter case we act as if SIGG(active) is false. */
- if (tsrm_is_shutdown() || !tsrm_is_managed_thread()) {
- /* Forward to default handler handler */
- zend_signal_handler(signo, siginfo, context);
- return;
- }
-#endif
-
- if (EXPECTED(SIGG(active))) {
- if (UNEXPECTED(SIGG(depth) == 0)) { /* try to handle signal */
- if (UNEXPECTED(SIGG(blocked))) {
- SIGG(blocked) = 0;
- }
- if (EXPECTED(SIGG(running) == 0)) {
- SIGG(running) = 1;
- zend_signal_handler(signo, siginfo, context);
-
- queue = SIGG(phead);
- SIGG(phead) = NULL;
-
- while (queue) {
- zend_signal_handler(queue->zend_signal.signo, queue->zend_signal.siginfo, queue->zend_signal.context);
- qtmp = queue->next;
- queue->next = SIGG(pavail);
- queue->zend_signal.signo = 0;
- SIGG(pavail) = queue;
- queue = qtmp;
- }
- SIGG(running) = 0;
- }
- } else { /* delay signal handling */
- SIGG(blocked) = 1; /* signal is blocked */
-
- if ((queue = SIGG(pavail))) { /* if none available it's simply forgotten */
- SIGG(pavail) = queue->next;
- queue->zend_signal.signo = signo;
- queue->zend_signal.siginfo = siginfo;
- queue->zend_signal.context = context;
- queue->next = NULL;
-
- if (SIGG(phead) && SIGG(ptail)) {
- SIGG(ptail)->next = queue;
- } else {
- SIGG(phead) = queue;
- }
- SIGG(ptail) = queue;
- }
-#if ZEND_DEBUG
- else { /* this may not be safe to do, but could work and be useful */
- zend_output_debug_string(0, "zend_signal: not enough queue storage, lost signal (%d)", signo);
- }
-#endif
- }
- } else {
- /* need to just run handler if we're inactive and getting a signal */
- zend_signal_handler(signo, siginfo, context);
- }
-
- errno = errno_save;
-} /* }}} */
-
-/* {{{ zend_signal_handler_unblock
- * Handle deferred signal from HANDLE_UNBLOCK_ALARMS */
-ZEND_API void zend_signal_handler_unblock(void)
-{
- zend_signal_queue_t *queue;
- zend_signal_t zend_signal;
-
- if (EXPECTED(SIGG(active))) {
- SIGNAL_BEGIN_CRITICAL(); /* procmask to protect handler_defer as if it were called by the kernel */
- queue = SIGG(phead);
- SIGG(phead) = queue->next;
- zend_signal = queue->zend_signal;
- queue->next = SIGG(pavail);
- queue->zend_signal.signo = 0;
- SIGG(pavail) = queue;
-
- zend_signal_handler_defer(zend_signal.signo, zend_signal.siginfo, zend_signal.context);
- SIGNAL_END_CRITICAL();
- }
-}
-/* }}} */
-
-/* {{{ zend_signal_handler
- * Call the previously registered handler for a signal
- */
-static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context)
-{
- int errno_save = errno;
- struct sigaction sa;
- sigset_t sigset;
- zend_signal_entry_t p_sig;
-#ifdef ZTS
- if (tsrm_is_shutdown() || !tsrm_is_managed_thread()) {
- p_sig = global_orig_handlers[signo-1];
- } else
-#endif
- p_sig = SIGG(handlers)[signo-1];
-
- if (p_sig.handler == SIG_DFL) { /* raise default handler */
- if (sigaction(signo, NULL, &sa) == 0) {
- sa.sa_handler = SIG_DFL;
- sigemptyset(&sa.sa_mask);
-
- sigemptyset(&sigset);
- sigaddset(&sigset, signo);
-
- if (sigaction(signo, &sa, NULL) == 0) {
- /* throw away any blocked signals */
- zend_sigprocmask(SIG_UNBLOCK, &sigset, NULL);
-#ifdef ZTS
- if (raise(signo) != 0) {
- /* On some systems raise() fails with errno 3: No such process */
- kill(getpid(), signo);
- }
-#else
- kill(getpid(), signo);
-#endif
- }
- }
- } else if (p_sig.handler != SIG_IGN) {
- if (p_sig.flags & SA_SIGINFO) {
- if (p_sig.flags & SA_RESETHAND) {
- SIGG(handlers)[signo-1].flags = 0;
- SIGG(handlers)[signo-1].handler = SIG_DFL;
- }
- (*(void (*)(int, siginfo_t*, void*))p_sig.handler)(signo, siginfo, context);
- } else {
- (*(void (*)(int))p_sig.handler)(signo);
- }
- }
-
- errno = errno_save;
-} /* }}} */
-
-/* {{{ zend_sigaction
- * Register a signal handler that will be deferred in critical sections */
-ZEND_API void zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact)
-{
- struct sigaction sa;
- sigset_t sigset;
-
- if (oldact != NULL) {
- oldact->sa_flags = SIGG(handlers)[signo-1].flags;
- oldact->sa_handler = (void *) SIGG(handlers)[signo-1].handler;
- oldact->sa_mask = global_sigmask;
- }
- if (act != NULL) {
- SIGG(handlers)[signo-1].flags = act->sa_flags;
- if (act->sa_flags & SA_SIGINFO) {
- SIGG(handlers)[signo-1].handler = (void *) act->sa_sigaction;
- } else {
- SIGG(handlers)[signo-1].handler = (void *) act->sa_handler;
- }
-
- memset(&sa, 0, sizeof(sa));
- if (SIGG(handlers)[signo-1].handler == (void *) SIG_IGN) {
- sa.sa_sigaction = (void *) SIG_IGN;
- } else {
- sa.sa_flags = SA_ONSTACK | SA_SIGINFO | (act->sa_flags & SA_FLAGS_MASK);
- sa.sa_sigaction = zend_signal_handler_defer;
- sa.sa_mask = global_sigmask;
- }
-
- if (sigaction(signo, &sa, NULL) < 0) {
- zend_error_noreturn(E_ERROR, "Error installing signal handler for %d", signo);
- }
-
- /* unsure this signal is not blocked */
- sigemptyset(&sigset);
- sigaddset(&sigset, signo);
- zend_sigprocmask(SIG_UNBLOCK, &sigset, NULL);
- }
-}
-/* }}} */
-
-/* {{{ zend_signal
- * Register a signal handler that will be deferred in critical sections */
-ZEND_API void zend_signal(int signo, void (*handler)(int))
-{
- struct sigaction sa;
-
- memset(&sa, 0, sizeof(sa));
- sa.sa_flags = 0;
- sa.sa_handler = handler;
- sa.sa_mask = global_sigmask;
-
- zend_sigaction(signo, &sa, NULL);
-}
-/* }}} */
-
-/* {{{ zend_signal_register
- * Set a handler for a signal we want to defer.
- * Previously set handler must have been saved before.
- */
-static zend_result zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*))
-{
- struct sigaction sa;
-
- if (sigaction(signo, NULL, &sa) == 0) {
- if ((sa.sa_flags & SA_SIGINFO) && sa.sa_sigaction == handler) {
- return FAILURE;
- }
-
- SIGG(handlers)[signo-1].flags = sa.sa_flags;
- if (sa.sa_flags & SA_SIGINFO) {
- SIGG(handlers)[signo-1].handler = (void *)sa.sa_sigaction;
- } else {
- SIGG(handlers)[signo-1].handler = (void *)sa.sa_handler;
- }
-
- sa.sa_flags = SA_SIGINFO; /* we'll use a siginfo handler */
- sa.sa_sigaction = handler;
- sa.sa_mask = global_sigmask;
-
- if (sigaction(signo, &sa, NULL) < 0) {
- zend_error_noreturn(E_ERROR, "Error installing signal handler for %d", signo);
- }
-
- return SUCCESS;
- }
- return FAILURE;
-} /* }}} */
-
-/* {{{ zend_signal_activate
- * Install our signal handlers, per request */
-void zend_signal_activate(void)
-{
- size_t x;
-
- memcpy(&SIGG(handlers), &global_orig_handlers, sizeof(global_orig_handlers));
-
- if (SIGG(reset)) {
- for (x = 0; x < sizeof(zend_sigs) / sizeof(*zend_sigs); x++) {
- zend_signal_register(zend_sigs[x], zend_signal_handler_defer);
- }
- }
-
- SIGG(active) = 1;
- SIGG(depth) = 0;
-} /* }}} */
-
-/* {{{ zend_signal_deactivate */
-void zend_signal_deactivate(void)
-{
- if (SIGG(check)) {
- size_t x;
- struct sigaction sa;
-
- if (SIGG(depth) != 0) {
- zend_error(E_CORE_WARNING, "zend_signal: shutdown with non-zero blocking depth (%d)", SIGG(depth));
- }
-
- /* did anyone steal our installed handler */
- for (x = 0; x < sizeof(zend_sigs) / sizeof(*zend_sigs); x++) {
- sigaction(zend_sigs[x], NULL, &sa);
- if (sa.sa_sigaction != zend_signal_handler_defer &&
- sa.sa_sigaction != (void *) SIG_IGN) {
- zend_error(E_CORE_WARNING, "zend_signal: handler was replaced for signal (%d) after startup", zend_sigs[x]);
- }
- }
- }
-
- /* After active=0 is set, signal handlers will be called directly and other
- * state that is reset below will not be accessed. */
- *((volatile int *) &SIGG(active)) = 0;
-
- SIGG(running) = 0;
- SIGG(blocked) = 0;
- SIGG(depth) = 0;
-
- /* If there are any queued signals because of a missed unblock, drop them. */
- if (SIGG(phead) && SIGG(ptail)) {
- SIGG(ptail)->next = SIGG(pavail);
- SIGG(pavail) = SIGG(phead);
- SIGG(phead) = NULL;
- SIGG(ptail) = NULL;
- }
-}
-/* }}} */
-
-static void zend_signal_globals_ctor(zend_signal_globals_t *zend_signal_globals) /* {{{ */
-{
- size_t x;
-
- memset(zend_signal_globals, 0, sizeof(*zend_signal_globals));
- zend_signal_globals->reset = 1;
-
- for (x = 0; x < sizeof(zend_signal_globals->pstorage) / sizeof(*zend_signal_globals->pstorage); ++x) {
- zend_signal_queue_t *queue = &zend_signal_globals->pstorage[x];
- queue->zend_signal.signo = 0;
- queue->next = zend_signal_globals->pavail;
- zend_signal_globals->pavail = queue;
- }
-}
-/* }}} */
-
-void zend_signal_init(void) /* {{{ */
-{
- int signo;
- struct sigaction sa;
-
- /* Save previously registered signal handlers into orig_handlers */
- memset(&global_orig_handlers, 0, sizeof(global_orig_handlers));
- for (signo = 1; signo < NSIG; ++signo) {
- if (sigaction(signo, NULL, &sa) == 0) {
- global_orig_handlers[signo-1].flags = sa.sa_flags;
- if (sa.sa_flags & SA_SIGINFO) {
- global_orig_handlers[signo-1].handler = (void *) sa.sa_sigaction;
- } else {
- global_orig_handlers[signo-1].handler = (void *) sa.sa_handler;
- }
- }
- }
-}
-/* }}} */
-
-/* {{{ zend_signal_startup
- * alloc zend signal globals */
-ZEND_API void zend_signal_startup(void)
-{
-
-#ifdef ZTS
- ts_allocate_tls_id(&zend_signal_globals_id, zend_signal_globals_tls_addr, sizeof(zend_signal_globals_t), (ts_allocate_ctor) zend_signal_globals_ctor, NULL);
-#else
- zend_signal_globals_ctor(&zend_signal_globals);
-#endif
-
- /* Used to block signals during execution of signal handlers */
- sigfillset(&global_sigmask);
- sigdelset(&global_sigmask, SIGILL);
- sigdelset(&global_sigmask, SIGABRT);
- sigdelset(&global_sigmask, SIGFPE);
- sigdelset(&global_sigmask, SIGKILL);
- sigdelset(&global_sigmask, SIGSEGV);
- sigdelset(&global_sigmask, SIGCONT);
- sigdelset(&global_sigmask, SIGSTOP);
- sigdelset(&global_sigmask, SIGTSTP);
- sigdelset(&global_sigmask, SIGTTIN);
- sigdelset(&global_sigmask, SIGTTOU);
-#ifdef SIGBUS
- sigdelset(&global_sigmask, SIGBUS);
-#endif
-#ifdef SIGSYS
- sigdelset(&global_sigmask, SIGSYS);
-#endif
-#ifdef SIGTRAP
- sigdelset(&global_sigmask, SIGTRAP);
-#endif
-
- zend_signal_init();
-}
-/* }}} */
-
-
-#endif /* ZEND_SIGNALS */
diff --git a/Zend/zend_signal.h b/Zend/zend_signal.h
deleted file mode 100644
index 171c40a483f4..000000000000
--- a/Zend/zend_signal.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | Zend Signal Handling |
- +----------------------------------------------------------------------+
- | Copyright © The PHP Group and Contributors. |
- +----------------------------------------------------------------------+
- | This source file is subject to the Modified BSD License that is |
- | bundled with this package in the file LICENSE, and is available |
- | through the World Wide Web at . |
- | |
- | SPDX-License-Identifier: BSD-3-Clause |
- +----------------------------------------------------------------------+
- | Authors: Lucas Nealan |
- | Arnaud Le Blanc |
- +----------------------------------------------------------------------+
- */
-
-#ifndef ZEND_SIGNAL_H
-#define ZEND_SIGNAL_H
-
-#ifdef ZEND_SIGNALS
-
-#include
-
-#include "zend_portability.h"
-
-#ifndef NSIG
-#define NSIG 65
-#endif
-
-#ifndef ZEND_SIGNAL_QUEUE_SIZE
-#define ZEND_SIGNAL_QUEUE_SIZE 64
-#endif
-
-/* Signal structs */
-typedef struct _zend_signal_entry_t {
- int flags; /* sigaction style flags */
- void* handler; /* signal handler or context */
-} zend_signal_entry_t;
-
-typedef struct _zend_signal_t {
- int signo;
- siginfo_t *siginfo;
- void* context;
-} zend_signal_t;
-
-typedef struct _zend_signal_queue_t {
- zend_signal_t zend_signal;
- struct _zend_signal_queue_t *next;
-} zend_signal_queue_t;
-
-/* Signal Globals */
-typedef struct _zend_signal_globals_t {
- int depth;
- int blocked; /* 1==TRUE, 0==FALSE */
- int running; /* in signal handler execution */
- int active; /* internal signal handling is enabled */
- bool check; /* check for replaced handlers on shutdown */
- bool reset; /* reset signal handlers on each request */
- zend_signal_entry_t handlers[NSIG];
- zend_signal_queue_t pstorage[ZEND_SIGNAL_QUEUE_SIZE], *phead, *ptail, *pavail; /* pending queue */
-} zend_signal_globals_t;
-
-# ifdef ZTS
-BEGIN_EXTERN_C()
-ZEND_API extern int zend_signal_globals_id;
-# ifdef ZEND_TLS_DIRECT
-# define SIGG(v) (zend_signal_globals.v)
-extern ZEND_TLS_API TSRM_TLS TSRM_TLS_MODEL_ATTR zend_signal_globals_t zend_signal_globals;
-# else
-# define SIGG(v) ZEND_TSRMG(zend_signal_globals_id, zend_signal_globals_t *, v)
-# endif
-END_EXTERN_C()
-# else
-# define SIGG(v) (zend_signal_globals.v)
-BEGIN_EXTERN_C()
-ZEND_API extern zend_signal_globals_t zend_signal_globals;
-END_EXTERN_C()
-# endif /* not ZTS */
-
-# ifdef ZTS
-# define ZEND_SIGNAL_BLOCK_INTERRUPTIONS() if (EXPECTED(zend_signal_globals_id)) { SIGG(depth)++; }
-# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (EXPECTED(zend_signal_globals_id) && UNEXPECTED(((SIGG(depth)--) == SIGG(blocked)))) { zend_signal_handler_unblock(); }
-# else /* ZTS */
-# define ZEND_SIGNAL_BLOCK_INTERRUPTIONS() SIGG(depth)++;
-# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (((SIGG(depth)--) == SIGG(blocked))) { zend_signal_handler_unblock(); }
-# endif /* not ZTS */
-
-ZEND_API void zend_signal_handler_unblock(void);
-void zend_signal_activate(void);
-void zend_signal_deactivate(void);
-BEGIN_EXTERN_C()
-ZEND_API void zend_signal_startup(void);
-END_EXTERN_C()
-void zend_signal_init(void);
-
-ZEND_API void zend_signal(int signo, void (*handler)(int));
-ZEND_API void zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact);
-
-#else /* ZEND_SIGNALS */
-
-# define ZEND_SIGNAL_BLOCK_INTERRUPTIONS()
-# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
-
-# define zend_signal_activate()
-# define zend_signal_deactivate()
-# define zend_signal_startup()
-# define zend_signal_init()
-
-# define zend_signal(signo, handler) signal(signo, handler)
-# define zend_sigaction(signo, act, oldact) sigaction(signo, act, oldact)
-
-#endif /* ZEND_SIGNALS */
-
-#endif /* ZEND_SIGNAL_H */
diff --git a/configure.ac b/configure.ac
index 40675011a2c0..d351714d1a4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -575,6 +575,7 @@ AC_CHECK_FUNCS([
setenv
setitimer
shutdown
+ sigaction
sigprocmask
splice
statfs
@@ -1813,7 +1814,6 @@ PHP_ADD_SOURCES([Zend], m4_normalize([
zend_partial.c
zend_property_hooks.c
zend_ptr_stack.c
- zend_signal.c
zend_smart_str.c
zend_sort.c
zend_stack.c
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index f5756e8be9be..95899c16cd41 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -928,7 +928,6 @@ static zend_string* ZEND_FASTCALL accel_replace_string_by_shm_permanent(zend_str
static void accel_use_shm_interned_strings(void)
{
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
zend_shared_alloc_lock();
@@ -943,7 +942,6 @@ static void accel_use_shm_interned_strings(void)
zend_shared_alloc_unlock();
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
}
#ifndef ZEND_WIN32
@@ -1393,7 +1391,6 @@ zend_string *accel_make_persistent_key(zend_string *str)
zend_string *str = accel_find_interned_string(cwd_str);
if (!str) {
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
zend_shared_alloc_lock();
str = accel_new_interned_string(zend_string_copy(cwd_str));
@@ -1403,7 +1400,6 @@ zend_string *accel_make_persistent_key(zend_string *str)
}
zend_shared_alloc_unlock();
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
}
if (str) {
char buf[32];
@@ -1437,7 +1433,6 @@ zend_string *accel_make_persistent_key(zend_string *str)
zend_string *str = accel_find_interned_string(ZCG(include_path));
if (!str) {
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
zend_shared_alloc_lock();
str = accel_new_interned_string(zend_string_copy(ZCG(include_path)));
@@ -1447,7 +1442,6 @@ zend_string *accel_make_persistent_key(zend_string *str)
}
zend_shared_alloc_unlock();
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
}
if (str) {
char buf[32];
@@ -1588,11 +1582,9 @@ zend_result zend_accel_invalidate(zend_string *filename, bool force)
if (force ||
!ZCG(accel_directives).validate_timestamps ||
do_validate_timestamps(persistent_script, &file_handle) == FAILURE) {
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
zend_accel_lock_discard_script(persistent_script);
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
}
file_handle.opened_path = NULL;
@@ -2058,11 +2050,9 @@ static zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int
}
}
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
persistent_script = zend_file_cache_script_load(file_handle);
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
if (persistent_script) {
/* see bug #15471 (old BTS) */
if (persistent_script->script.filename) {
@@ -2327,7 +2317,6 @@ zend_op_array *zend_accel_compile_pfa(zend_ast *ast,
new_persistent_script->warnings = EG(errors).errors;
}
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
bool from_shared_memory;
@@ -2341,7 +2330,6 @@ zend_op_array *zend_accel_compile_pfa(zend_ast *ast,
gc_enable(orig_gc_state);
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
/* We may have switched to an existing persistent script that was persisted in
* the meantime. Make sure to use its warnings if available. */
@@ -2443,13 +2431,11 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
persistent_script = (zend_persistent_script *)bucket->data;
if (key && !persistent_script->corrupted) {
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
zend_shared_alloc_lock();
zend_accel_add_key(key, bucket);
zend_shared_alloc_unlock();
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
}
}
}
@@ -2493,7 +2479,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
return NULL;
}
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
/* If script is found then validate_timestamps if option is enabled */
@@ -2520,7 +2505,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
/* No memory left. Behave like without the Accelerator */
if (ZSMMG(memory_exhausted) || ZCSG(restart_pending)) {
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
if (ZCG(accel_directives).file_cache) {
return file_cache_compile_file(file_handle, type);
}
@@ -2530,9 +2514,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
zend_begin_record_errors();
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
persistent_script = opcache_compile_file(file_handle, type, &op_array);
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
/* Try and cache the script and assume that it is returned from_shared_memory.
@@ -2556,7 +2538,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
*/
if (!persistent_script) {
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
zend_emit_recorded_errors();
zend_free_recorded_errors();
return op_array;
@@ -2571,7 +2552,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
}
persistent_script->dynamic_members.last_used = ZCG(request_time);
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
/* We may have switched to an existing persistent script that was persisted in
* the meantime. Make sure to use its warnings if available. */
@@ -2622,7 +2602,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
}
persistent_script->dynamic_members.last_used = ZCG(request_time);
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
zend_emit_recorded_errors_ex(persistent_script->num_warnings, persistent_script->warnings);
from_shared_memory = true;
@@ -2968,13 +2947,11 @@ static zend_string* persistent_zend_resolve_path(zend_string *filename)
if (!persistent_script->corrupted) {
if (key) {
/* add another "key" for the same bucket */
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
zend_shared_alloc_lock();
zend_accel_add_key(key, bucket);
zend_shared_alloc_unlock();
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
} else {
ZSTR_LEN(ZCG(key)) = 0;
}
@@ -3068,7 +3045,6 @@ ZEND_RINIT_FUNCTION(zend_accelerator)
}
#endif
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
if (ZCG(counted)) {
@@ -3161,7 +3137,6 @@ ZEND_RINIT_FUNCTION(zend_accelerator)
#endif
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
/* Called once the SHM lock is released and the memory is protected again */
if (UNEXPECTED(restarted) && zend_accel_restart_hook) {
@@ -3985,7 +3960,6 @@ void zend_accel_schedule_restart(zend_accel_restart_reason reason)
zend_accel_error(ACCEL_LOG_DEBUG, "Restart Scheduled! Reason: %s",
zend_accel_restart_reason_text[reason]);
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
ZCSG(restart_pending) = true;
ZCSG(restart_reason) = reason;
@@ -3998,7 +3972,6 @@ void zend_accel_schedule_restart(zend_accel_restart_reason reason)
ZCSG(force_restart_time) = 0;
}
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
}
static void accel_deactivate_now(void)
@@ -5221,13 +5194,11 @@ static zend_result accel_preload(const char *config, bool in_child)
zend_shared_alloc_init_xlat_table();
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
ZCSG(preload_script) = preload_script_in_shared_memory(script);
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
preload_load(orig_map_ptr_static_last);
@@ -5238,7 +5209,6 @@ static zend_result accel_preload(const char *config, bool in_child)
EG(persistent_constants_count) = EG(zend_constants)->nNumUsed;
/* Store individual scripts with unlinked classes */
- HANDLE_BLOCK_INTERRUPTIONS();
SHM_UNPROTECT();
i = 0;
@@ -5270,7 +5240,6 @@ static zend_result accel_preload(const char *config, bool in_child)
#endif
SHM_PROTECT();
- HANDLE_UNBLOCK_INTERRUPTIONS();
zend_shared_alloc_destroy_xlat_table();
} else {
@@ -5324,9 +5293,6 @@ static zend_result accel_finish_startup_preload(bool in_child)
char *(*orig_getenv)(const char *name, size_t name_len) = sapi_module.getenv;
size_t (*orig_ub_write)(const char *str, size_t str_length) = sapi_module.ub_write;
void (*orig_flush)(void *server_context) = sapi_module.flush;
-#ifdef ZEND_SIGNALS
- bool old_reset_signals = SIGG(reset);
-#endif
ZCG(preloading) = true;
@@ -5342,10 +5308,6 @@ static zend_result accel_finish_startup_preload(bool in_child)
zend_interned_strings_switch_storage(1);
-#ifdef ZEND_SIGNALS
- SIGG(reset) = false;
-#endif
-
orig_error_reporting = EG(error_reporting);
EG(error_reporting) = 0;
@@ -5380,11 +5342,6 @@ static zend_result accel_finish_startup_preload(bool in_child)
orig_report_memleaks = PG(report_memleaks);
PG(report_memleaks) = false;
-#ifdef ZEND_SIGNALS
- /* We may not have registered signal handlers due to SIGG(reset)=0, so
- * also disable the check that they are registered. */
- SIGG(check) = false;
-#endif
php_request_shutdown(NULL); /* calls zend_shared_alloc_unlock(); */
EG(class_table) = NULL;
EG(function_table) = NULL;
@@ -5398,9 +5355,6 @@ static zend_result accel_finish_startup_preload(bool in_child)
zend_shared_alloc_unlock();
ret = FAILURE;
}
-#ifdef ZEND_SIGNALS
- SIGG(reset) = old_reset_signals;
-#endif
sapi_module.activate = orig_activate;
sapi_module.deactivate = orig_deactivate;
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 87eb1f8ac158..22972284d263 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -192,6 +192,27 @@ 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);
+static void pcntl_original_handler_dtor(zval *zv)
+{
+ efree(Z_PTR_P(zv));
+}
+
+/* Keeps the handler installed before the request (by the SAPI or host) for RSHUTDOWN to restore */
+static void pcntl_save_original_handler(int signo)
+{
+ struct sigaction oact;
+
+ if (zend_hash_index_exists(&PCNTL_G(original_handlers), signo)) {
+ return;
+ }
+
+ memset(&oact, 0, sizeof(oact));
+ if (sigaction(signo, NULL, &oact) != 0) {
+ return;
+ }
+ zend_hash_index_add_mem(&PCNTL_G(original_handlers), signo, &oact, sizeof(oact));
+}
+
static PHP_GINIT_FUNCTION(pcntl)
{
#if defined(COMPILE_DL_PCNTL) && defined(ZTS)
@@ -204,6 +225,7 @@ PHP_RINIT_FUNCTION(pcntl)
{
php_add_tick_function(pcntl_signal_dispatch_tick_function, NULL);
zend_hash_init(&PCNTL_G(php_signal_table), 16, NULL, ZVAL_PTR_DTOR, 0);
+ zend_hash_init(&PCNTL_G(original_handlers), 0, NULL, pcntl_original_handler_dtor, 0);
PCNTL_G(head) = PCNTL_G(tail) = PCNTL_G(spares) = NULL;
PCNTL_G(async_signals) = 0;
PCNTL_G(last_error) = 0;
@@ -231,16 +253,12 @@ PHP_MINIT_FUNCTION(pcntl)
PHP_RSHUTDOWN_FUNCTION(pcntl)
{
struct php_pcntl_pending_signal *sig;
- zend_long signo;
- zval *handle;
- /* 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, false);
- }
+ ZEND_HASH_FOREACH_NUM_KEY_PTR(&PCNTL_G(original_handlers), zend_ulong signo, struct sigaction *oact) {
+ sigaction((int) signo, oact, NULL);
} ZEND_HASH_FOREACH_END();
+ zend_hash_destroy(&PCNTL_G(original_handlers));
zend_hash_destroy(&PCNTL_G(php_signal_table));
while (PCNTL_G(head)) {
@@ -820,7 +838,6 @@ PHP_FUNCTION(pcntl_signal)
RETURN_THROWS();
}
- /* sigaction() always fails for these, and zend_sigaction() turns that into a fatal error */
if (signo == SIGKILL || signo == SIGSTOP) {
PCNTL_G(last_error) = EINVAL;
php_error_docref(NULL, E_WARNING, "Error assigning signal");
@@ -846,6 +863,8 @@ PHP_FUNCTION(pcntl_signal)
restart_syscalls = 0;
}
+ pcntl_save_original_handler((int) signo);
+
/* Special long value case for SIG_DFL and SIG_IGN */
if (Z_TYPE_P(handle) == IS_LONG) {
if (php_signal(signo, (Sigfunc *) Z_LVAL_P(handle), restart_syscalls) == (void *)SIG_ERR) {
diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h
index aaf1ea0ad473..6a71e1a2fdfb 100644
--- a/ext/pcntl/php_pcntl.h
+++ b/ext/pcntl/php_pcntl.h
@@ -41,6 +41,7 @@ struct php_pcntl_pending_signal {
ZEND_BEGIN_MODULE_GLOBALS(pcntl)
HashTable php_signal_table;
+ HashTable original_handlers;
bool processing_signal_queue;
volatile bool pending_signals;
bool async_signals;
diff --git a/ext/pcntl/php_signal.c b/ext/pcntl/php_signal.c
index b0357d86f02b..25b14f15fc46 100644
--- a/ext/pcntl/php_signal.c
+++ b/ext/pcntl/php_signal.c
@@ -15,7 +15,6 @@
#include "TSRM.h"
#include "php_signal.h"
#include "Zend/zend.h"
-#include "Zend/zend_signal.h"
/* php_signal using sigaction is derived from Advanced Programming
* in the Unix Environment by W. Richard Stevens p 298. */
@@ -40,7 +39,9 @@ Sigfunc *php_signal4(int signo, Sigfunc *func, bool restart, bool mask_all)
act.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */
#endif
}
- zend_sigaction(signo, &act, &oact);
+ if (sigaction(signo, &act, &oact) < 0) {
+ return (Sigfunc *) (void *) SIG_ERR;
+ }
return oact.sa_sigaction;
}
diff --git a/ext/pcntl/tests/pcntl_signal_restore_previous_handler.phpt b/ext/pcntl/tests/pcntl_signal_restore_previous_handler.phpt
new file mode 100644
index 000000000000..163d0723e454
--- /dev/null
+++ b/ext/pcntl/tests/pcntl_signal_restore_previous_handler.phpt
@@ -0,0 +1,34 @@
+--TEST--
+pcntl_signal() handlers are replaced by the previous handler, not SIG_DFL, at request shutdown
+--EXTENSIONS--
+pcntl
+--SKIPIF--
+
+--FILE--
+processHandle, SIGPIPE);
+usleep(200000);
+
+echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/");
+?>
+--EXPECT--
+ok
+ok
diff --git a/ext/pdo_firebird/pdo_firebird.c b/ext/pdo_firebird/pdo_firebird.c
index 74ba7f8994ca..ed8822f4bc8f 100644
--- a/ext/pdo_firebird/pdo_firebird.c
+++ b/ext/pdo_firebird/pdo_firebird.c
@@ -69,11 +69,6 @@ PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
PdoFirebird_ce = register_class_Pdo_Firebird(pdo_dbh_ce);
PdoFirebird_ce->create_object = pdo_dbh_new;
-#ifdef ZEND_SIGNALS
- /* firebird replaces some signals at runtime, suppress warnings. */
- SIGG(check) = 0;
-#endif
-
return php_pdo_register_driver_specific_ce(&pdo_firebird_driver, PdoFirebird_ce);
}
/* }}} */
diff --git a/ext/readline/tests/libedit_callback_handler_install_001.phpt b/ext/readline/tests/libedit_callback_handler_install_001.phpt
index a98027fbb9eb..233f3dfd7946 100644
--- a/ext/readline/tests/libedit_callback_handler_install_001.phpt
+++ b/ext/readline/tests/libedit_callback_handler_install_001.phpt
@@ -7,8 +7,6 @@ readline
---INI--
-zend.signal_check=0
--ENV--
LSAN_OPTIONS=detect_leaks=0
--FILE--
diff --git a/ext/readline/tests/libedit_callback_handler_remove_001.phpt b/ext/readline/tests/libedit_callback_handler_remove_001.phpt
index 1c7185c1bba6..8e3771213950 100644
--- a/ext/readline/tests/libedit_callback_handler_remove_001.phpt
+++ b/ext/readline/tests/libedit_callback_handler_remove_001.phpt
@@ -7,8 +7,6 @@ readline
---INI--
-zend.signal_check=0
--ENV--
LSAN_OPTIONS=detect_leaks=0
--FILE--
diff --git a/ext/standard/info.c b/ext/standard/info.c
index 097f5900bc32..c129893672f4 100644
--- a/ext/standard/info.c
+++ b/ext/standard/info.c
@@ -859,12 +859,6 @@ PHPAPI ZEND_COLD void php_print_info(int flag)
php_info_print_table_row(2, "Thread Safety", "disabled" );
#endif
-#ifdef ZEND_SIGNALS
- php_info_print_table_row(2, "Zend Signal Handling", "enabled" );
-#else
- php_info_print_table_row(2, "Zend Signal Handling", "disabled" );
-#endif
-
php_info_print_table_row(2, "Zend Memory Manager", is_zend_mm() ? "enabled" : "disabled" );
{
diff --git a/ext/standard/tests/general_functions/phpinfo.phpt b/ext/standard/tests/general_functions/phpinfo.phpt
index a7503ec0bc41..3498c5758ce1 100644
--- a/ext/standard/tests/general_functions/phpinfo.phpt
+++ b/ext/standard/tests/general_functions/phpinfo.phpt
@@ -32,7 +32,6 @@ PHP Extension Build => API%s
PHP Integer Size => %d bits
Debug Build => %s
Thread Safety => %r(.+?)%r
-Zend Signal Handling => %s
Zend Memory Manager => %s
Zend Multibyte Support => %s
Zend Max Execution Timers => %s
diff --git a/main/main.c b/main/main.c
index 0267c6839137..3c7441c02ab8 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1924,10 +1924,6 @@ zend_result php_request_startup(void)
php_basic_early_rinit();
sapi_activate();
-#ifdef ZEND_SIGNALS
- zend_signal_activate();
-#endif
-
if (PG(max_input_time) == -1) {
zend_set_timeout(EG(timeout_seconds), 1);
} else {
@@ -2086,11 +2082,6 @@ void php_request_shutdown(void *dummy)
* At this point, no memory beyond a single chunk should be in use. */
zend_set_memory_limit(PG(memory_limit));
- /* 17. Deactivate Zend signals */
-#ifdef ZEND_SIGNALS
- zend_signal_deactivate();
-#endif
-
#ifdef PHP_WIN32
if (PG(com_initialized)) {
CoUninitialize();
diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c
index 67585e84b78b..608598b77126 100644
--- a/sapi/apache2handler/sapi_apache2.c
+++ b/sapi/apache2handler/sapi_apache2.c
@@ -498,8 +498,6 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp
# endif
#endif
- zend_signal_startup();
-
sapi_startup(&apache2_sapi_module);
if (apache2_sapi_module.startup(&apache2_sapi_module) != SUCCESS) {
return DONE;
@@ -756,20 +754,10 @@ static void php_apache_child_init(apr_pool_t *pchild, server_rec *s)
php_child_init();
}
-#ifdef ZEND_SIGNALS
-static void php_apache_signal_init(apr_pool_t *pchild, server_rec *s)
-{
- zend_signal_init();
-}
-#endif
-
void php_ap2_register_hook(apr_pool_t *p)
{
ap_hook_pre_config(php_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_post_config(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_handler(php_handler, NULL, NULL, APR_HOOK_MIDDLE);
-#ifdef ZEND_SIGNALS
- ap_hook_child_init(php_apache_signal_init, NULL, NULL, APR_HOOK_MIDDLE);
-#endif
ap_hook_child_init(php_apache_child_init, NULL, NULL, APR_HOOK_MIDDLE);
}
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 632b6adaa9e3..5bcae5278cf2 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -1762,8 +1762,6 @@ int main(int argc, char *argv[])
# endif
#endif
- zend_signal_startup();
-
#ifdef ZTS
ts_allocate_id(&php_cgi_globals_id, sizeof(php_cgi_globals_struct), (ts_allocate_ctor) php_cgi_globals_ctor, NULL);
#else
@@ -2044,7 +2042,6 @@ consult the installation file that came with this distribution, or visit \n\
sigaction(SIGTERM, &old_term, 0);
sigaction(SIGQUIT, &old_quit, 0);
sigaction(SIGINT, &old_int, 0);
- zend_signal_init();
break;
case -1:
perror("php (pre-forking)");
@@ -2084,7 +2081,6 @@ consult the installation file that came with this distribution, or visit \n\
}
} else {
parent = 0;
- zend_signal_init();
}
#else
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 80c498354f6a..d623c73c1118 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -1252,8 +1252,6 @@ PHP_CLI_API int do_php_cli(int argc, char *argv[])
# endif
#endif
- zend_signal_startup();
-
#ifdef PHP_WIN32
_fmode = _O_BINARY; /*sets default for file streams to binary */
_setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index a82d07d4f226..16e3cef48123 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -2975,8 +2975,6 @@ int do_cli_server(int argc, char **argv) /* {{{ */
signal(SIGPIPE, SIG_IGN);
#endif
- zend_signal_init();
-
if (SUCCESS != php_cli_server_do_event_loop(&server)) {
r = 1;
}
diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
index 3be8db4cc014..1885515e12d8 100644
--- a/sapi/embed/php_embed.c
+++ b/sapi/embed/php_embed.c
@@ -170,8 +170,6 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv)
# endif
#endif
- zend_signal_startup();
-
/* SAPI initialization (SINIT)
*
* Initialize the SAPI globals (memset to 0). After this point we can set
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c
index 3d35e942a06e..75fb89360aea 100644
--- a/sapi/fpm/fpm/fpm_main.c
+++ b/sapi/fpm/fpm/fpm_main.c
@@ -1577,8 +1577,6 @@ int main(int argc, char *argv[])
php_tsrm_startup();
#endif
- zend_signal_startup();
-
sapi_startup(&cgi_sapi_module);
cgi_sapi_module.php_ini_path_override = NULL;
cgi_sapi_module.php_ini_ignore_cwd = 1;
diff --git a/sapi/fpm/fpm/fpm_signals.c b/sapi/fpm/fpm/fpm_signals.c
index aca7c9ed58cc..43cf0328f3cc 100644
--- a/sapi/fpm/fpm/fpm_signals.c
+++ b/sapi/fpm/fpm/fpm_signals.c
@@ -249,8 +249,6 @@ int fpm_signals_init_child(void)
return -1;
}
- zend_signal_init();
-
if (0 > fpm_signals_unblock()) {
return -1;
}
diff --git a/sapi/fuzzer/fuzzer-sapi.c b/sapi/fuzzer/fuzzer-sapi.c
index a64b1c0a4a45..762022f5d266 100644
--- a/sapi/fuzzer/fuzzer-sapi.c
+++ b/sapi/fuzzer/fuzzer-sapi.c
@@ -159,8 +159,6 @@ int fuzzer_init_php(const char *extra_ini)
# endif
#endif
- zend_signal_startup();
-
sapi_startup(&fuzzer_module);
fuzzer_module.phpinfo_as_text = 1;
@@ -202,12 +200,6 @@ int fuzzer_request_startup(void)
return FAILURE;
}
-#ifdef ZEND_SIGNALS
- /* Some signal handlers will be overridden,
- * don't complain about them during shutdown. */
- SIGG(check) = 0;
-#endif
-
fuzzer_disable_classes();
return SUCCESS;
diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c
index 90b9921a84cf..258f1398fd12 100644
--- a/sapi/litespeed/lsapi_main.c
+++ b/sapi/litespeed/lsapi_main.c
@@ -1473,12 +1473,6 @@ int main( int argc, char * argv[] )
php_tsrm_startup();
#endif
-#if PHP_MAJOR_VERSION >= 7
-#if defined(ZEND_SIGNALS) || PHP_MINOR_VERSION > 0
- zend_signal_startup();
-#endif
-#endif
-
if (argc > 1 ) {
if ( parse_opt( argc, argv, &climode,
&php_ini_path, &php_bind ) == -1 ) {
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index e7ee47f09b22..d18fae9fbb6d 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -1053,7 +1053,7 @@ static void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) /* {{
if (PHPDBG_G(sigsegv_bailout)) {
LONGJMP(*PHPDBG_G(sigsegv_bailout), FAILURE);
}
- zend_sigaction(sig, &PHPDBG_G(old_sigsegv_signal), NULL);
+ sigaction(sig, &PHPDBG_G(old_sigsegv_signal), NULL);
}
break;
}
@@ -1166,8 +1166,6 @@ int main(int argc, char **argv) /* {{{ */
# endif
#endif
- zend_signal_startup();
-
php_ini_builder_init(&ini_builder);
ini_ignore = 0;
ini_override = NULL;
@@ -1390,12 +1388,8 @@ int main(int argc, char **argv) /* {{{ */
goto free_and_return;
}
- zend_try {
- zend_signal_activate();
- } zend_end_try();
-
#ifndef _WIN32
- zend_signal(SIGHUP, phpdbg_sighup_handler);
+ signal(SIGHUP, phpdbg_sighup_handler);
#endif
mm_heap = zend_mm_get_heap();
@@ -1458,11 +1452,11 @@ int main(int argc, char **argv) /* {{{ */
if (!PHPDBG_G(watch_userfaultfd))
#endif
{
- zend_try { zend_sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); } zend_end_try();
- zend_try { zend_sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); } zend_end_try();
+ sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal));
+ sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal));
}
#endif
- zend_try { zend_signal(SIGINT, phpdbg_sigint_handler); } zend_end_try();
+ signal(SIGINT, phpdbg_sigint_handler);
PHPDBG_G(io)[PHPDBG_STDIN].fd = fileno(stdin);
@@ -1728,7 +1722,7 @@ int main(int argc, char **argv) /* {{{ */
}
#ifndef _WIN32
- /* force override (no zend_signals) to prevent crashes due to signal recursion in SIGSEGV/SIGBUS handlers */
+ /* prevent crashes due to signal recursion in SIGSEGV/SIGBUS handlers */
signal(SIGSEGV, SIG_DFL);
signal(SIGBUS, SIG_DFL);
diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h
index 6aa9c9f696a5..895abffac10b 100644
--- a/sapi/phpdbg/phpdbg.h
+++ b/sapi/phpdbg/phpdbg.h
@@ -37,8 +37,7 @@
#include "zend_globals.h"
#include "zend_ini_scanner.h"
#include "zend_stream.h"
-#include "zend_signal.h"
-#if !defined(_WIN32) && !defined(ZEND_SIGNALS)
+#if !defined(_WIN32)
# include
#elif defined(PHP_WIN32)
# include "win32/signal.h"