* master_cleanup() now passes along an exit code from its caller to the OS.
authorArt Cancro <ajc@citadel.org>
Wed, 16 Feb 2005 19:03:38 +0000 (19:03 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 16 Feb 2005 19:03:38 +0000 (19:03 +0000)
citadel/ChangeLog
citadel/citserver.c
citadel/citserver.h
citadel/housekeeping.c
citadel/server_main.c
citadel/sysdep.c

index a9145bac33f4719bf83c933176f64ccf31a87c7e..a687a2d5ae538be53c2439dc380308f86a514557 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 640.10  2005/02/16 19:03:38  ajc
+ * master_cleanup() now passes along an exit code from its caller to the OS.
+
  Revision 640.9  2005/02/16 18:48:39  ajc
  * Try to reach our cleanup routine when SIGSEGV is caught.  Hopefully
    we'll get there and we can close the databases cleanly.
@@ -6408,3 +6411,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 0ff5725e990db6ccb23c327c7b3b438446a4083a..88a7ad0ad5beb72fba8d1ea94b02070067531939 100644 (file)
@@ -125,10 +125,8 @@ void master_startup(void) {
 
 /*
  * Cleanup routine to be called when the server is shutting down.
- * WARNING: It's no longer safe to call this function to force a shutdown.
- * Instead, set time_to_die = 1.
  */
-void master_cleanup(void) {
+void master_cleanup(int exitcode) {
        struct CleanupFunctionHook *fcn;
        static int already_cleaning_up = 0;
 
@@ -152,9 +150,9 @@ void master_cleanup(void) {
 #endif
 
        /* Now go away. */
-       lprintf(CTDL_NOTICE, "citserver: exiting.\n");
+       lprintf(CTDL_NOTICE, "citserver: Exiting with status %d.\n", exitcode);
        fflush(stdout); fflush(stderr);
-       exit(0);
+       exit(exitcode);
 }
 
 
index 2288541bea976c1dfbeba57ec4153da259eda266..b5d27a243ff000f1f70c59ba076fbb1ae9627dae 100644 (file)
@@ -13,7 +13,7 @@ struct UserProcList {
 };
 
 void master_startup (void);
-void master_cleanup (void);
+void master_cleanup (int exitcode);
 void RemoveContext (struct CitContext *);
 void set_wtmpsupp (char *newtext);
 void set_wtmpsupp_to_current_room(void);
index 1b8deeb9a264359939af70fa54815864fb6e81e6..9bb4624bb379271d056e8da9321dfcb7e42f4e8d 100644 (file)
@@ -82,7 +82,7 @@ void check_sched_shutdown(void) {
        if ((ScheduledShutdown == 1) && (ContextList == NULL)) {
                lprintf(CTDL_NOTICE, "Scheduled shutdown initiating.\n");
                time_to_die = 1;
-               master_cleanup();
+               master_cleanup(0);
        }
 }
 
index 6e25f3cc6fab49556ef8bfc9dffcf7433dce4dc9..c4d6c5e24ec9fcde51321878cd2156d2c4c49e8b 100644 (file)
@@ -229,6 +229,6 @@ int main(int argc, char **argv)
 
        /* Server is exiting. Wait for workers to shutdown. */
        lprintf(CTDL_INFO, "Server is shutting down.\n");
-       master_cleanup();
+       master_cleanup(0);
        return(0);
 }
index 4457591a4c8e43923db0842db166d2ef99cc9a32..5b51e1286cb02f8600d3e1c57ed8304a57fd34d6 100644 (file)
@@ -160,12 +160,7 @@ void lprintf(enum LogLevel loglevel, const char *format, ...) {
 
 
 /*
- * We used to use master_cleanup() as a signal handler to shut down the server.
- * however, master_cleanup() and the functions it calls do some things that
- * aren't such a good idea to do from a signal handler: acquiring mutexes,
- * playing with signal masks on BSDI systems, etc. so instead we install the
- * following signal handler to set a global variable to inform the main loop
- * that it's time to call master_cleanup() and exit.
+ * Signal handler to shut down the server.
  */
 
 volatile int time_to_die = 0;
@@ -173,7 +168,7 @@ volatile int time_to_die = 0;
 static RETSIGTYPE signal_cleanup(int signum) {
        lprintf(CTDL_DEBUG, "Caught signal %d; shutting down.\n", signum);
        time_to_die = 1;
-       master_cleanup();       /* will this work? */
+       master_cleanup(signum);
 }