]> code.citadel.org Git - citadel.git/blobdiff - citadel/citserver.c
CONF LOADVAL and CONF STOREVAL to handle configuration variables with length greater...
[citadel.git] / citadel / citserver.c
index 9f41f35f56bc9d55ee2e9827cae596631bc99f63..447d68f066850b15e15e895795b36c2f289e3c94 100644 (file)
  * GNU General Public License for more details.
  */
 
+#include <stdlib.h>
+#include <unistd.h>
 #include <stdio.h>
+#include <sys/stat.h>
 #include "sysdep.h"
 #include <time.h>
 #if HAVE_BACKTRACE
@@ -185,9 +188,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 +228,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);
 }