Module: kamailio
Branch: master
Commit: 06aec5a81cb22d06ad3bf613a05951f91e7e21bc
URL:
https://github.com/kamailio/kamailio/commit/06aec5a81cb22d06ad3bf613a05951f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-02-03T08:29:32+01:00
core: use macro for exit variants based on --no-atexit
---
Modified: src/core/daemonize.c
Modified: src/main.c
---
Diff:
https://github.com/kamailio/kamailio/commit/06aec5a81cb22d06ad3bf613a05951f…
Patch:
https://github.com/kamailio/kamailio/commit/06aec5a81cb22d06ad3bf613a05951f…
---
diff --git a/src/core/daemonize.c b/src/core/daemonize.c
index 4eb7e1f25a..8dcf7363e2 100644
--- a/src/core/daemonize.c
+++ b/src/core/daemonize.c
@@ -300,13 +300,13 @@ int daemonize(char* name, int status_wait)
}else if (pid!=0){
if (status_wait) {
if (daemon_status_wait(&pipe_status) == 0) {
- exit((int)pipe_status);
+ ksr_exit(ksr_no_atexit, (int)pipe_status);
} else {
LM_ERR("Main process exited before writing to pipe\n");
- exit(-1);
+ ksr_exit(ksr_no_atexit, -1);
}
}
- exit(0);
+ ksr_exit(ksr_no_atexit, 0);
}
if (status_wait)
daemon_status_no_wait(); /* clean unused read fd */
@@ -322,7 +322,7 @@ int daemonize(char* name, int status_wait)
goto error;
}else if (pid!=0){
/*parent process => exit */
- exit(0);
+ ksr_exit(ksr_no_atexit, 0);
}
}
diff --git a/src/main.c b/src/main.c
index 39160f4f4b..3942f5c8c3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -741,11 +741,7 @@ void handle_sigs(void)
LM_NOTICE("Thank you for flying " NAME "!!!\n");
/* shutdown/kill all the children */
shutdown_children(SIGTERM, 1);
- if(ksr_no_atexit==1) {
- _exit(0);
- } else {
- exit(0);
- }
+ ksr_exit(ksr_no_atexit, 0);
break;
case SIGUSR1:
@@ -813,17 +809,9 @@ void handle_sigs(void)
/* exit */
shutdown_children(SIGTERM, 1);
if (WIFSIGNALED(chld_status)) {
- if(ksr_no_atexit==1) {
- _exit(1);
- } else {
- exit(1);
- }
+ ksr_exit(ksr_no_atexit, 1);
} else {
- if(ksr_no_atexit==1) {
- _exit(0);
- } else {
- exit(0);
- }
+ ksr_exit(ksr_no_atexit, 0);
}
break;