summaryrefslogtreecommitdiff
path: root/lib/sigevent.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2021-04-16 04:38:25 +0200
committerDavid Lamparter <equinox@diac24.net>2021-04-19 05:35:04 +0200
commit5be4799dc5f16049ecb7a681974e69a7cbe415b9 (patch)
tree8989cd157d791447aab45d783dcfd6efe35b1c31 /lib/sigevent.c
parent79ec61be278b1af8fd9da0f9494bc91be0c3384d (diff)
lib: don't print 2 backtraces for crashes
abort() raises SIGABRT, which would confusingly cause a 2nd backtrace to be printed after the first one... Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/sigevent.c')
-rw-r--r--lib/sigevent.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/sigevent.c b/lib/sigevent.c
index 64cec1385d..be7297f264 100644
--- a/lib/sigevent.c
+++ b/lib/sigevent.c
@@ -237,9 +237,12 @@ core_handler(int signo, siginfo_t *siginfo, void *context)
/* make sure we don't hang in here. default for SIGALRM is terminate.
* - if we're in backtrace for more than a second, abort. */
struct sigaction sa_default = {.sa_handler = SIG_DFL};
+
sigaction(SIGALRM, &sa_default, NULL);
+ sigaction(signo, &sa_default, NULL);
sigset_t sigset;
+
sigemptyset(&sigset);
sigaddset(&sigset, SIGALRM);
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
@@ -252,7 +255,16 @@ core_handler(int signo, siginfo_t *siginfo, void *context)
log_memstats(stderr, "core_handler");
zlog_tls_buffer_fini();
- abort();
+
+ /* give the kernel a chance to generate a coredump */
+ sigaddset(&sigset, signo);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
+ raise(signo);
+
+ /* only chance to end up here is if the default action for signo is
+ * something other than kill or coredump the process
+ */
+ _exit(128 + signo);
}
static void trap_default_signals(void)