From: Victor Julien Date: Mon, 17 Jul 2017 09:02:47 +0000 (+0200) Subject: mingw: fix compilation of signals code X-Git-Tag: suricata-4.1.0-beta1~402 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e113fa96e9a45d8c20ba4d71b732ca4ade747ce0;p=thirdparty%2Fsuricata.git mingw: fix compilation of signals code --- diff --git a/src/suricata.c b/src/suricata.c index fd8b8d4796..a9b7fc49a3 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -286,7 +286,7 @@ static void SignalHandlerSigterm(/*@unused@*/ int sig) { sigterm_count = 1; } - +#ifndef OS_WIN32 /** * SIGUSR2 handler. Just set sigusr2_count. The main loop will act on * it. @@ -305,6 +305,7 @@ static void SignalHandlerSigHup(/*@unused@*/ int sig) { sighup_count = 1; } +#endif #ifdef DBG_MEM_ALLOC #ifndef _GLOBAL_MEM_ @@ -2143,7 +2144,6 @@ static int WindowsInitService(int argc, char **argv) return -1; } SCLogInfo("Current directory is set to: %s", path); - daemon = 1; SCServiceInit(argc, argv); } @@ -2196,14 +2196,12 @@ static int InitSignalHandler(SCInstance *suri) { /* registering signals we use */ UtilSignalHandlerSetup(SIGINT, SignalHandlerSigint); - UtilSignalHandlerSetup(SIGUSR2, SignalHandlerSigusr2); UtilSignalHandlerSetup(SIGTERM, SignalHandlerSigterm); - UtilSignalHandlerSetup(SIGPIPE, SIG_IGN); - UtilSignalHandlerSetup(SIGSYS, SIG_IGN); - #ifndef OS_WIN32 - /* SIGHUP is not implemented on WIN32 */ + UtilSignalHandlerSetup(SIGUSR2, SignalHandlerSigusr2); UtilSignalHandlerSetup(SIGHUP, SignalHandlerSigHup); + UtilSignalHandlerSetup(SIGPIPE, SIG_IGN); + UtilSignalHandlerSetup(SIGSYS, SIG_IGN); /* Try to get user/group to run suricata as if command line as not decide of that */ @@ -2512,13 +2510,14 @@ static int ConfigGetCaptureValue(SCInstance *suri) static void PostRunStartedDetectSetup(SCInstance *suri) { +#ifndef OS_WIN32 /* registering signal handlers we use. We register usr2 here, so that one * can't call it during the first sig load phase or while threads are still * starting up. */ if (DetectEngineEnabled() && suri->sig_file == NULL && suri->delayed_detect == 0) UtilSignalHandlerSetup(SIGUSR2, SignalHandlerSigusr2); - +#endif if (suri->delayed_detect) { /* force 'reload', this will load the rules and swap engines */ DetectEngineReload(suri); @@ -2848,7 +2847,7 @@ int main(int argc, char **argv) #ifdef OS_WIN32 /* service initialization */ - if (WindowsInit(argc, argv) != 0) { + if (WindowsInitService(argc, argv) != 0) { exit(EXIT_FAILURE); } #endif /* OS_WIN32 */ diff --git a/src/util-signal.c b/src/util-signal.c index 4dc43e4a43..dada13316a 100644 --- a/src/util-signal.c +++ b/src/util-signal.c @@ -28,6 +28,7 @@ int UtilSignalBlock(int signum) { +#ifndef OS_WIN32 sigset_t x; if (sigemptyset(&x) < 0) return -1; @@ -35,7 +36,7 @@ int UtilSignalBlock(int signum) return -1; if (sigprocmask(SIG_BLOCK, &x, NULL) < 0) return -1; - +#endif return 0; } @@ -57,6 +58,7 @@ void UtilSignalHandlerSetup(int sig, void (*handler)(int)) return; } +#if 0 int UtilSignalIsHandler(int sig, void (*handler)(int)) { struct sigaction action; @@ -66,3 +68,4 @@ int UtilSignalIsHandler(int sig, void (*handler)(int)) return (action.sa_handler == handler); } +#endif diff --git a/src/util-signal.h b/src/util-signal.h index 1c1c85ab27..171d1b5536 100644 --- a/src/util-signal.h +++ b/src/util-signal.h @@ -26,6 +26,7 @@ int UtilSignalBlock(int); void UtilSignalHandlerSetup(int, void (*handler)(int)); +#if 0 int UtilSignalIsHandler(int sig, void (*handler)(int)); - +#endif #endif /* __UTIL_SIGNAL_H__ */