]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
log/stack: Propagate original signal 7215/head
authorJeff Lucovsky <jeff@lucovsky.org>
Fri, 11 Feb 2022 15:38:45 +0000 (10:38 -0500)
committerVictor Julien <vjulien@oisf.net>
Thu, 7 Apr 2022 17:30:44 +0000 (19:30 +0200)
Issue: 4550

This commit modifies the "stack trace on signal" to propagate the
original signal received instead of always raising SIGABRT.

(cherry picked from commit a3443845fbaf5c01bb8758817490bc93b5c039a5)

src/suricata.c

index 8e3fad9aed63a5af4de26f00eb377ef3734c3f34..ee0c9e9bcc102e2dc042ffd30294b2a462e4de9c 100644 (file)
@@ -300,6 +300,9 @@ static void SignalHandlerUnexpected(int sig_num, siginfo_t *info, void *context)
 {
     char msg[SC_LOG_MAX_LOG_MSG_LEN];
     unw_cursor_t cursor;
+    /* Restore defaults for signals to avoid loops */
+    signal(SIGABRT, SIG_DFL);
+    signal(SIGSEGV, SIG_DFL);
     int r;
     if ((r = unw_init_local(&cursor, (unw_context_t *)(context)) != 0)) {
         fprintf(stderr, "unable to obtain stack trace: unw_init_local: %s\n", unw_strerror(r));
@@ -332,9 +335,8 @@ static void SignalHandlerUnexpected(int sig_num, siginfo_t *info, void *context)
     SCLogError(SC_ERR_SIGNAL, "%s", msg);
 
 terminate:
-    // Terminate with SIGABRT ... but first, restore that signal's default handling
-    signal(SIGABRT, SIG_DFL);
-    abort();
+    // Propagate signal to watchers, if any
+    kill(0, sig_num);
 }
 #undef UNW_LOCAL_ONLY
 #endif /* HAVE_LIBUNWIND */