From f78e990915803893c83dadb75b83d89cc12701e4 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 24 Mar 2016 10:21:11 +0100 Subject: [PATCH] signals: handle INT/TERM signals in the main loop --- src/suricata.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/suricata.c b/src/suricata.c index cbdea55150..05e5ffde7c 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -276,12 +276,10 @@ int RunmodeGetCurrent(void) static void SignalHandlerSigint(/*@unused@*/ int sig) { sigint_count = 1; - suricata_ctl_flags |= SURICATA_STOP; } static void SignalHandlerSigterm(/*@unused@*/ int sig) { sigterm_count = 1; - suricata_ctl_flags |= SURICATA_KILL; } void SignalHandlerSigusr2StartingUp(int sig) @@ -2442,9 +2440,14 @@ int main(int argc, char **argv) int engine_retval = EXIT_SUCCESS; while(1) { + if (sigterm_count) { + suricata_ctl_flags |= SURICATA_KILL; + } else if (sigint_count) { + suricata_ctl_flags |= SURICATA_STOP; + } + if (suricata_ctl_flags & (SURICATA_KILL | SURICATA_STOP)) { SCLogNotice("Signal Received. Stopping engine."); - break; } -- 2.47.2