Demo entry 6624890

Code

   

Submitted by anonymous on Jun 18, 2017 at 16:23
Language: C. Code size: 1.7 kB.

static void InitSignals(void)
{
#ifndef WIN32
# if defined(LINUX) || defined(FREEBSD) || defined(OPENBSD) || \
                   defined(SOLARIS) || defined(BSD) || defined(MACOS)
	sigset_t set;

	sigemptyset(&set);
#  if defined(INLINE_FAILOPEN) || \
                    defined(TARGET_BASED) || defined(SNORT_RELOAD)
	pthread_sigmask(SIG_SETMASK, &set, NULL);
#  else
	sigprocmask(SIG_SETMASK, &set, NULL);
#  endif /* INLINE_FAILOPEN */
# else
	sigsetmask(0);
# endif /* LINUX, BSD, SOLARIS */
#endif  /* !WIN32 */

	/* Make this prog behave nicely when signals come along.
                   * Windows doesn't like all of these signals, and will
                   * set errno for some.  Ignore/reset this error so it
                   * doesn't interfere with later checks of errno value.  */
	signal_error_msg[0] = '\0';
	SnortAddSignal(SIGTERM, SigExitHandler, 1);
	SnortAddSignal(SIGINT, SigExitHandler, 1);
#ifndef WIN32
	SnortAddSignal(SIGQUIT, SigExitHandler, 1);
	SnortAddSignal(SIGNAL_SNORT_DUMP_STATS, SigDumpStatsHandler, 1);
	SnortAddSignal(SIGNAL_SNORT_RELOAD, SigReloadHandler, 1);
	SnortAddSignal(SIGNAL_SNORT_ROTATE_STATS, SigRotateStatsHandler, 1);
#endif

#ifdef CONTROL_SOCKET
	SnortAddSignal(SIGPIPE, SigPipeHandler, 1);
#endif

#ifdef TARGET_BASED
#ifndef WIN32
	/* Used to print warning if attribute table is not configured
                   * When it is, it will set new signal handler */
	SnortAddSignal(SIGNAL_SNORT_READ_ATTR_TBL, SigNoAttributeTableHandler, 1);
#endif
#endif

	SnortAddSignal(SIGABRT, SigOopsHandler, 1);
	SnortAddSignal(SIGSEGV, SigOopsHandler, 1);
#ifndef WIN32
	SnortAddSignal(SIGBUS, SigOopsHandler, 1);
#endif

	errno = 0;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).