From: Victor Julien Date: Thu, 24 Mar 2016 09:21:11 +0000 (+0100) Subject: signals: handle INT/TERM signals in the main loop X-Git-Tag: suricata-3.0.1~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f78e990915803893c83dadb75b83d89cc12701e4;p=thirdparty%2Fsuricata.git signals: handle INT/TERM signals in the main loop --- 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; }