]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Use bclose_from() in daemon.c
authorEric Bollengier <eric@baculasystems.com>
Thu, 4 Jul 2024 15:26:34 +0000 (17:26 +0200)
committerEric Bollengier <eric@baculasystems.com>
Wed, 4 Dec 2024 08:14:26 +0000 (09:14 +0100)
bacula/src/lib/daemon.c

index a8ef8d81a807e6422c6845b0ae75f3d34cbbe7ef..f18690291e06eab86447a8c45d2ca81a58713d1a 100644 (file)
@@ -75,27 +75,7 @@ daemon_start()
       next_fd = 3;                    /* don't close debug output */
    }
 
-#if defined(HAVE_FCNTL_F_CLOSEM)
-   fcntl(next_fd, F_CLOSEM);
-#elif defined(HAVE_CLOSEFROM)
-   closefrom(next_fd);
-#else
-   struct rlimit rl;
-   int64_t rlimitResult=0;
-
-   /* Many systems doesn't have the correct system call
-    * to determine the FD list to close.
-    */
-   if (getrlimit(RLIMIT_NOFILE, &rl) == -1) {
-      rlimitResult = sysconf(_SC_OPEN_MAX);
-   } else {
-      rlimitResult = rl.rlim_max;
-   }
-
-   for (i=rlimitResult; i >= next_fd; i--) {
-      close(i);
-   }
-#endif
+   bclose_from(next_fd);
 
    /* Move to root directory. For debug we stay
     * in current directory so dumps go there.