Module: kamailio
Branch: master
Commit: 9f12d314268d1d2cd990cb3c5556f79343869e47
URL:
https://github.com/kamailio/kamailio/commit/9f12d314268d1d2cd990cb3c5556f79…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-02-01T23:39:40+01:00
core: added --no-atexit cli parameter
- skip atexit callbacks execution from external libraries which may access
destroyed shm memory causing crash on shutdown
---
Modified: src/main.c
---
Diff:
https://github.com/kamailio/kamailio/commit/9f12d314268d1d2cd990cb3c5556f79…
Patch:
https://github.com/kamailio/kamailio/commit/9f12d314268d1d2cd990cb3c5556f79…
---
diff --git a/src/main.c b/src/main.c
index fa18b3221e..39160f4f4b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -209,7 +209,9 @@ Options:\n\
#ifdef USE_TCP
" -N Number of tcp child processes (default: equal to
`-n')\n"
#endif
-" -O nr Script optimization level (debugging option)\n\
+" --no-atexit Skip atexit callbacks execution from external libraries\n\
+ which may access destroyed shm memory causing crash on shutdown\n\
+ -O nr Script optimization level (debugging option)\n\
-P file Create a pid file\n"
#ifdef USE_SCTP
" -Q Number of sctp child processes (default: equal to
`-n')\n"
@@ -535,6 +537,7 @@ char *sr_memmng_shm = NULL;
static int *_sr_instance_started = NULL;
int ksr_cfg_print_mode = 0;
+int ksr_no_atexit = 0;
/**
* return 1 if all child processes were forked
@@ -738,7 +741,11 @@ void handle_sigs(void)
LM_NOTICE("Thank you for flying " NAME "!!!\n");
/* shutdown/kill all the children */
shutdown_children(SIGTERM, 1);
- exit(0);
+ if(ksr_no_atexit==1) {
+ _exit(0);
+ } else {
+ exit(0);
+ }
break;
case SIGUSR1:
@@ -806,9 +813,17 @@ void handle_sigs(void)
/* exit */
shutdown_children(SIGTERM, 1);
if (WIFSIGNALED(chld_status)) {
- exit(1);
+ if(ksr_no_atexit==1) {
+ _exit(1);
+ } else {
+ exit(1);
+ }
} else {
- exit(0);
+ if(ksr_no_atexit==1) {
+ _exit(0);
+ } else {
+ exit(0);
+ }
}
break;
@@ -1938,6 +1953,7 @@ int main(int argc, char** argv)
{"log-engine", required_argument, 0, KARGOPTVAL + 7},
{"debug", required_argument, 0, KARGOPTVAL + 8},
{"cfg-print", no_argument, 0, KARGOPTVAL + 9},
+ {"no-atexit", no_argument, 0, KARGOPTVAL + 10},
{0, 0, 0, 0 }
};
@@ -2011,6 +2027,9 @@ int main(int argc, char** argv)
case KARGOPTVAL+9:
ksr_cfg_print_mode = 1;
break;
+ case KARGOPTVAL+10:
+ ksr_no_atexit = 1;
+ break;
default:
if (c == 'h' || (optarg && strcmp(optarg, "-h") == 0)) {
@@ -2174,6 +2193,7 @@ int main(int argc, char** argv)
case KARGOPTVAL+7:
case KARGOPTVAL+8:
case KARGOPTVAL+9:
+ case KARGOPTVAL+10:
break;
/* long options */