X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fcitserver.c;h=f389ac9f020b303551e62769d12c4d9135ea9b6c;hb=e6499f44a49d449e41ba605a0c7476019da432b4;hp=9f41f35f56bc9d55ee2e9827cae596631bc99f63;hpb=3052311a6d7a2b14d2ff24edff6344cf1ae109b4;p=citadel.git diff --git a/citadel/citserver.c b/citadel/citserver.c index 9f41f35f5..f389ac9f0 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -185,9 +185,9 @@ void master_startup(void) { /* - * Cleanup routine to be called when the server is shutting down. + * Cleanup routine to be called when the server is shutting down. Returns the needed exit code. */ -void master_cleanup(int exitcode) { +int master_cleanup(int exitcode) { struct CleanupFunctionHook *fcn; static int already_cleaning_up = 0; @@ -225,11 +225,13 @@ void master_cleanup(int exitcode) { syslog(LOG_NOTICE, "citserver: Exiting with status %d\n", exitcode); fflush(stdout); fflush(stderr); - if (restart_server != 0) - exit(1); - if ((running_as_daemon != 0) && ((exitcode == 0) )) + if (restart_server != 0) { + exitcode = 1; + } + else if ((running_as_daemon != 0) && ((exitcode == 0) )) { exitcode = CTDLEXIT_SHUTDOWN; - exit(exitcode); + } + return(exitcode); }