summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-11-25 18:43:10 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2020-11-25 18:44:46 +0100
commitefb88bf5ffe5aa1a8116ee118ef9104e4afc3873 (patch)
tree6fb1e96159c04958b3d0c8541473113b328851c4
parent581cfbeba985d078e80c8ec330f79396201fdb6f (diff)
trxcon: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL + retriggering SIGABRT in case the signal handler returns, which would then generate the coredump + terminate the process. However, if a SIGABRT is received from somewhere else (kill -SIGABRT), then the process would print the talloc report and continue running, which is not desired. Change-Id: I6d80f3f2742d397e47f4f2970c951f2cf6d58172 Fixes: OS#4865
-rw-r--r--src/host/trxcon/trxcon.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/host/trxcon/trxcon.c b/src/host/trxcon/trxcon.c
index e14e2c90..158e27f7 100644
--- a/src/host/trxcon/trxcon.c
+++ b/src/host/trxcon/trxcon.c
@@ -241,15 +241,25 @@ static void init_defaults(void)
app_data.quit = 0;
}
-static void signal_handler(int signal)
+static void signal_handler(int signum)
{
- fprintf(stderr, "signal %u received\n", signal);
+ fprintf(stderr, "signal %u received\n", signum);
- switch (signal) {
+ switch (signum) {
case SIGINT:
app_data.quit++;
break;
case SIGABRT:
+ /* in case of abort, we want to obtain a talloc report and
+ * then run default SIGABRT handler, who will generate coredump
+ * and abort the process. abort() should do this for us after we
+ * return, but program wouldn't exit if an external SIGABRT is
+ * received.
+ */
+ talloc_report_full(tall_trxcon_ctx, stderr);
+ signal(SIGABRT, SIG_DFL);
+ raise(SIGABRT);
+ break;
case SIGUSR1:
case SIGUSR2:
talloc_report_full(tall_trxcon_ctx, stderr);