$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.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
/*
* 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;
#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);
}
};
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);
if ((ScheduledShutdown == 1) && (ContextList == NULL)) {
lprintf(CTDL_NOTICE, "Scheduled shutdown initiating.\n");
time_to_die = 1;
- master_cleanup();
+ master_cleanup(0);
}
}
/* Server is exiting. Wait for workers to shutdown. */
lprintf(CTDL_INFO, "Server is shutting down.\n");
- master_cleanup();
+ master_cleanup(0);
return(0);
}
/*
- * 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;
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);
}