laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-mgw/+/36355?usp=email )


Change subject: mgw: Add our usual SIGABRT, USR1, USR2 signal handlers
......................................................................

mgw: Add our usual SIGABRT, USR1, USR2 signal handlers

This is mostly related to talloc reports.

Change-Id: Idc35444d2b8a0bc52c267b468dfa3c1b59f9187a
---
M src/osmo-mgw/mgw_main.c
1 file changed, 39 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/55/36355/1

diff --git a/src/osmo-mgw/mgw_main.c b/src/osmo-mgw/mgw_main.c
index 5a62e95..0e85e38 100644
--- a/src/osmo-mgw/mgw_main.c
+++ b/src/osmo-mgw/mgw_main.c
@@ -280,6 +280,31 @@
        return vty->node;
 }

+static void signal_handler(int signum)
+{
+       fprintf(stdout, "signal %u received\n", signum);
+
+       switch (signum) {
+       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(tall_vty_ctx, stderr);
+               talloc_report_full(tall_mgw_ctx, stderr);
+               signal(SIGABRT, SIG_DFL);
+               raise(SIGABRT);
+               break;
+       case SIGUSR1:
+               talloc_report(tall_vty_ctx, stderr);
+               talloc_report_full(tall_mgw_ctx, stderr);
+               break;
+       default:
+               break;
+       }
+}

 static struct vty_app_info vty_info = {
        .name           = "OsmoMGW",
@@ -328,6 +353,9 @@

        msgb_talloc_ctx_init(tall_mgw_ctx, 0);

+       signal(SIGABRT, &signal_handler);
+       signal(SIGUSR1, &signal_handler);
+       signal(SIGUSR2, &signal_handler);
        osmo_init_ignore_signals();
        osmo_init_logging2(tall_mgw_ctx, &log_info);
        libosmo_abis_init(tall_mgw_ctx);

--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/36355?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Idc35444d2b8a0bc52c267b468dfa3c1b59f9187a
Gerrit-Change-Number: 36355
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>
Gerrit-MessageType: newchange

Reply via email to