Re-enable SIGINT and SIGSEGV handler. All other signals are handled by the resolver code

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2018-02-25 00:06:12 +01:00
parent 39f46e38ac
commit 74c8a19d5f
3 changed files with 6 additions and 62 deletions
+3 -3
View File
@@ -41,9 +41,9 @@ int main (int argc, char* argv[])
read_FTLconf();
// Catch signals like SIGHUP, SIGUSR1, etc.
// TODO: Maybe we should have this handled by the dnsmasq part
//handle_signals();
// Catch signals like SIGTERM and SIGINT
// Other signals like SIGHUP, SIGUSR1 are handled by the resolver part
handle_signals();
// Initialize database
if(config.maxDBdays != 0)
+3
View File
@@ -97,3 +97,6 @@ void validate_access(const char * name, int pos, bool testmagic, int line, const
void validate_access_oTcl(int timeidx, int clientID, int line, const char * function, const char * file);
int main_dnsmasq(int argc, char **argv);
// signals.c
void handle_signals(void);
-59
View File
@@ -12,18 +12,9 @@
volatile sig_atomic_t killed = 0;
int FTLstarttime = 0;
bool rereadgravity = false;
static void SIGTERM_handler(int sig, siginfo_t *si, void *unused)
{
logg("FATAL: FTL received SIGTERM from PID/UID %i/%i, exiting gracefully", (int)si->si_pid, (int)si->si_uid);
timer_start(EXIT_TIMER);
killed = 1;
}
static void SIGINT_handler(int sig, siginfo_t *si, void *unused)
{
// Should probably not use printf in signal handler, but this will anyhow exit immediately
logg("FATAL: FTL received SIGINT (Ctrl + C, PID/UID %i/%i), exiting immediately!", (int)si->si_pid, (int)si->si_uid);
logg(" There may be queries that have not been saved in the long-term data base");
exit(EXIT_FAILURE);
@@ -70,33 +61,9 @@ static void SIGSEGV_handler(int sig, siginfo_t *si, void *unused)
abort();
}
static void SIGUSR1_handler(int signum)
{
logg("NOTICE: Received signal SIGUSR1 - re-parsing log files");
flush = true;
}
static void SIGHUP_handler(int signum)
{
logg("NOTICE: Received signal SIGHUP - re-reading gravity files");
rereadgravity = true;
}
void handle_signals(void)
{
// Catch SIGTERM
struct sigaction old_action;
sigaction (SIGTERM, NULL, &old_action);
if(old_action.sa_handler != SIG_IGN)
{
struct sigaction TERMaction;
memset(&TERMaction, 0, sizeof(struct sigaction));
TERMaction.sa_flags = SA_SIGINFO;
sigemptyset(&TERMaction.sa_mask);
TERMaction.sa_sigaction = &SIGTERM_handler;
sigaction(SIGTERM, &TERMaction, NULL);
}
// Catch SIGINT
sigaction (SIGTERM, NULL, &old_action);
if(old_action.sa_handler != SIG_IGN)
@@ -108,10 +75,6 @@ void handle_signals(void)
INTaction.sa_sigaction = &SIGINT_handler;
sigaction(SIGINT, &INTaction, NULL);
}
// Ignore SIGPIPE
signal(SIGPIPE, SIG_IGN);
// Catch SIGSEGV
sigaction (SIGSEGV, NULL, &old_action);
if(old_action.sa_handler != SIG_IGN)
@@ -124,28 +87,6 @@ void handle_signals(void)
sigaction(SIGSEGV, &SEGVaction, NULL);
}
// Catch SIGUSR1
sigaction (SIGUSR1, NULL, &old_action);
if(old_action.sa_handler != SIG_IGN)
{
struct sigaction USR1action;
memset(&USR1action, 0, sizeof(struct sigaction));
sigemptyset(&USR1action.sa_mask);
USR1action.sa_handler = &SIGUSR1_handler;
sigaction(SIGUSR1, &USR1action, NULL);
}
// Catch SIGHUP
sigaction (SIGHUP, NULL, &old_action);
if(old_action.sa_handler != SIG_IGN)
{
struct sigaction HUPaction;
memset(&HUPaction, 0, sizeof(struct sigaction));
sigemptyset(&HUPaction.sa_mask);
HUPaction.sa_handler = &SIGHUP_handler;
sigaction(SIGHUP, &HUPaction, NULL);
}
// Log start time of FTL
FTLstarttime = time(NULL);
}