Skip to content
Snippets Groups Projects
Commit fc90974e authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

signal handling: remove dead code

Remove the code which existed at times when we weren't
running everything inside an event loop, so required
alternative ways of signal handling in and out of an
event loop.

Reset signal handlers when handling fatal signals,
to avoid an infinite loop.
parent d3846db1
No related branches found
No related tags found
No related merge requests found
......@@ -211,22 +211,6 @@ sig_fatal_cb(int signo)
abort();
}
/**
* This SIGTERM handler is only used before the main event loop started to
* cleanup server pid file. The handler is replaced by ev_signal after the boot.
* @sa signal_start
*/
static void
sig_term_cb(int signo)
{
psignal(signo, "");
/* unlink pidfile. */
if (pid_file != NULL)
unlink(pid_file);
_exit(EXIT_SUCCESS);
}
static void
signal_free(void)
{
......@@ -239,6 +223,9 @@ signal_free(void)
static void
signal_reset()
{
for (int i = 0; i < ev_sig_count; i++)
ev_signal_stop(loop(), &ev_sigs[i]);
struct sigaction sa;
/* Reset all signals to their defaults. */
......@@ -254,9 +241,6 @@ signal_reset()
sigaction(SIGFPE, &sa, NULL) == -1)
say_syserror("sigaction");
for (int i = 0; i < ev_sig_count; i++)
ev_signal_stop(loop(), &ev_sigs[i]);
/* Unblock any signals blocked by libev. */
sigset_t sigset;
sigfillset(&sigset);
......@@ -286,6 +270,12 @@ signal_init(void)
if (sigaction(SIGPIPE, &sa, 0) == -1)
panic_syserror("sigaction");
/*
* SA_RESETHAND resets handler action to the default
* one when entering handler.
* SA_NODEFER allows receiving the same signal during handler.
*/
sa.sa_flags = SA_RESETHAND | SA_NODEFER;
sa.sa_handler = sig_fatal_cb;
if (sigaction(SIGSEGV, &sa, 0) == -1 ||
......@@ -293,14 +283,6 @@ signal_init(void)
panic_syserror("sigaction");
}
sa.sa_handler = sig_term_cb;
if (sigaction(SIGUSR1, &sa, 0) == -1 ||
sigaction(SIGINT, &sa, 0) == -1 ||
sigaction(SIGTERM, &sa, 0) == -1 ||
sigaction(SIGHUP, &sa, 0) == -1) {
panic_syserror("sigaction");
}
ev_signal_init(&ev_sigs[0], sig_snapshot, SIGUSR1);
ev_signal_init(&ev_sigs[1], signal_cb, SIGINT);
ev_signal_init(&ev_sigs[2], signal_cb, SIGTERM);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment