Change in osmo-bts[master]: sysmobts-mgr: generate coredump and exit upon SIGABRT received

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Wed Nov 25 18:09:17 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/21356 )


Change subject: sysmobts-mgr: generate coredump and exit upon SIGABRT received
......................................................................

sysmobts-mgr: 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: I35ae930b59c48892e5ad9a2826e05d6c5d415abc
Fixes: OS#4865
---
M src/osmo-bts-sysmo/misc/sysmobts_mgr.c
1 file changed, 14 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/56/21356/1

diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
index dc7af3c..61b08b4 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
@@ -192,11 +192,11 @@
 	return 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:
 	case SIGTERM:
 		sysmobts_check_temp(no_eeprom_write);
@@ -204,6 +204,16 @@
 		exit(0);
 		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_mgr_ctx, stderr);
+		signal(SIGABRT, SIG_DFL);
+		raise(SIGABRT);
+		break;
 	case SIGUSR1:
 	case SIGUSR2:
 		talloc_report_full(tall_mgr_ctx, stderr);
@@ -262,6 +272,7 @@
 	osmo_init_ignore_signals();
 	signal(SIGINT, &signal_handler);
 	signal(SIGTERM, &signal_handler);
+	signal(SIGABRT, &signal_handler);
 	signal(SIGUSR1, &signal_handler);
 	signal(SIGUSR2, &signal_handler);
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/21356
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I35ae930b59c48892e5ad9a2826e05d6c5d415abc
Gerrit-Change-Number: 21356
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201125/ea228635/attachment.htm>


More information about the gerrit-log mailing list