Skip to content

Commit

Permalink
core: use macro for exit variants based on --no-atexit
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Feb 3, 2021
1 parent b886ba5 commit 06aec5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/core/daemonize.c
Expand Up @@ -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 */
Expand All @@ -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);
}
}

Expand Down
18 changes: 3 additions & 15 deletions src/main.c
Expand Up @@ -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:
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 06aec5a

Please sign in to comment.