aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-11-25 18:57:19 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2020-11-25 18:57:43 +0100
commit54733225108a794a65febba52ec2346e039ec91e (patch)
tree05a414799f04ad00332f8a4ae643d46db3c4fbcb /openbsc/src
parent658c0c83fd6453e0ceb752d136c2cca3da235540 (diff)
bsc-nat: 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: Ie884be1f3e1d5ead912aafd0a78e1a0a97258ab8 Fixes: OS#4865
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 3376d39bc..90af4d780 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -1535,12 +1535,20 @@ static void handle_options(int argc, char **argv)
}
}
-static void signal_handler(int signal)
+static void signal_handler(int signum)
{
- switch (signal) {
+ switch (signum) {
case SIGABRT:
- /* in case of abort, we want to obtain a talloc report
- * and then return to the caller, who will abort the process */
+ /* 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_bsc_ctx, stderr);
+ signal(SIGABRT, SIG_DFL);
+ raise(SIGABRT);
+ break;
case SIGUSR1:
talloc_report_full(tall_bsc_ctx, stderr);
break;