pipe-logging-fix-20050610
[openafs.git] / src / bozo / bosserver.c
index b784849..90a8bca 100644 (file)
@@ -51,7 +51,6 @@ RCSID
 #define BOZO_LWP_STACKSIZE     16000
 extern int BOZO_ExecuteRequest();
 extern int RXSTATS_ExecuteRequest();
-extern int afsconf_GetKey();
 extern struct bnode_ops fsbnode_ops, ezbnode_ops, cronbnode_ops;
 
 void bozo_Log();
@@ -61,7 +60,6 @@ static char *bozo_pid;
 struct rx_securityClass *bozo_rxsc[3];
 const char *bozo_fileName;
 FILE *bozo_logFile;
-extern int rx_stackSize;       /* for rx_SetStackSize macro */
 
 int DoLogging = 0;
 int DoSyslog = 0;
@@ -582,6 +580,7 @@ tweak_config()
 }
 #endif
 
+#if 0
 /*
  * This routine causes the calling process to go into the background and
  * to lose its controlling tty.
@@ -703,6 +702,7 @@ background(void)
     }
 }
 #endif /* ! AFS_NT40_ENV */
+#endif
 
 /* start a process and monitor it */
 
@@ -720,6 +720,7 @@ main(int argc, char **argv, char **envp)
     char namebuf[AFSDIR_PATH_MAX];
 #ifndef AFS_NT40_ENV
     int nofork = 0;
+    struct stat sb;
 #endif
 #ifdef AFS_AIX32_ENV
     struct sigaction nsa;
@@ -858,14 +859,21 @@ main(int argc, char **argv, char **envp)
     fflush(stdout);
 #endif
 
-    /* go into the background and remove our controlling tty */
+    /* go into the background and remove our controlling tty, close open 
+       file desriptors
+     */
 
 #ifndef AFS_NT40_ENV
     if (!nofork)
-       background();
+       daemon(1, 0);
 #endif /* ! AFS_NT40_ENV */
 
-    if (!DoSyslog) {
+    if ((!DoSyslog)
+#ifndef AFS_NT40_ENV
+       && ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) && 
+       !(S_ISFIFO(sb.st_mode)))
+#endif
+       ) {
        strcpy(namebuf, AFSDIR_BOZLOG_FILE);
        strcat(namebuf, ".old");
        renamefile(AFSDIR_BOZLOG_FILE, namebuf);        /* try rename first */
@@ -966,8 +974,8 @@ main(int argc, char **argv, char **envp)
     rx_SetNoJumbo();
 
     tservice = rx_NewService( /* port */ 0, /* service id */ 1,
-                                                       /*service name */ "bozo",
-                                                       /* security classes */
+                            /*service name */ "bozo",
+                            /* security classes */
                             bozo_rxsc,
                             /* numb sec classes */ 3, BOZO_ExecuteRequest);
     rx_SetMinProcs(tservice, 2);