]> code.citadel.org Git - citadel.git/commitdiff
* added pid file writing
authorArt Cancro <ajc@citadel.org>
Mon, 28 Feb 2005 02:25:30 +0000 (02:25 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 28 Feb 2005 02:25:30 +0000 (02:25 +0000)
citadel/ChangeLog
citadel/citserver.c

index 22970ad729beb8c7d4b79bc4e004d4b6e036a24d..1008ece621da69a66b8949bb429317ba5e396802 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 641.7  2005/02/28 02:25:29  ajc
+ * added pid file writing
+
  Revision 641.6  2005/02/27 15:36:28  ajc
  * database_cleanup.sh: look for /usr/local/ctdlsupport/bin/db_dump and
    prepend that directory to the PATH if found.
@@ -6451,4 +6454,3 @@ 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 c2297a46920dce2608852fd3261bbca093c4c3fe..ee4b5ffcfd08d8a6a187ebce001f6815d25d8c8c 100644 (file)
@@ -68,6 +68,7 @@ char *unique_session_numbers;
 int ScheduledShutdown = 0;
 int do_defrag = 0;
 time_t server_startup_time;
+char pid_file_name[PATH_MAX];
 
 /*
  * Various things that need to be initialized at startup
@@ -77,10 +78,19 @@ void master_startup(void) {
        unsigned int seed;
        FILE *urandom;
        struct ctdlroom qrbuf;
+       FILE *pidfile_fp;
        
        lprintf(CTDL_DEBUG, "master_startup() started\n");
        time(&server_startup_time);
 
+       /* pid file.  If we go FSSTND this should end up in 'localstatedir' */
+       snprintf(pid_file_name, sizeof pid_file_name, "./citadel.pid");
+       pidfile_fp = fopen(pid_file_name, "w");
+       if (pidfile_fp != NULL) {
+               fprintf(pidfile_fp, "%d\n", (int)getpid());
+               fclose(pidfile_fp);
+       }
+
        lprintf(CTDL_INFO, "Opening databases\n");
        open_databases();
 
@@ -153,6 +163,7 @@ void master_cleanup(int exitcode) {
        lprintf(CTDL_NOTICE, "citserver: Exiting with status %d\n", exitcode);
        fflush(stdout); fflush(stderr);
 
+       unlink(pid_file_name);
        exit(exitcode);
 }