]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/daemon.c
Use the command line utility dropdb instead of the psql command
[bacula/bacula] / bacula / src / lib / daemon.c
index 01e11bb694101b2716754a68f5db789f1accb1d1..20dc2fdf52fb733cd95b327cb39dfa22d71824eb 100644 (file)
@@ -41,7 +41,7 @@ daemon_start()
 {
 #ifndef HAVE_CYGWIN
    int i;
-   int cpid;
+   pid_t cpid;
    mode_t oldmask;
    /*
     *  Become a daemon.
@@ -57,17 +57,10 @@ daemon_start()
    setsid();
 
    /* In the PRODUCTION system, we close ALL
-    * file descriptors. It is useful
-    * for debugging to leave the standard ones open.
+    * file descriptors except stdin, stdout, and stderr.
     */
-   for (i=sysconf(_SC_OPEN_MAX)-1; i >=0; i--) {
-#ifdef DEBUG
-      if (i != STDIN_FILENO && i != STDOUT_FILENO && i != STDERR_FILENO) {
-        close(i);
-      }
-#else 
+   for (i=sysconf(_SC_OPEN_MAX)-1; i > 2; i--) {
       close(i);
-#endif
    }
 
    /* Move to root directory. For debug we stay
@@ -81,8 +74,8 @@ daemon_start()
     * Avoid creating files 666 but don't override any
     * more restrictive mask set by the user.
     */
-   oldmask = umask(022);
-   oldmask |= 022;
+   oldmask = umask(026);
+   oldmask |= 026;
    umask(oldmask);
 
    Dmsg0(200, "Exit daemon_start\n");