]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
2001-10-08 Chip Salzenberg <chip@pobox.com>
authorchip <chip>
Mon, 8 Oct 2001 22:57:58 +0000 (22:57 +0000)
committerchip <chip>
Mon, 8 Oct 2001 22:57:58 +0000 (22:57 +0000)
* utils/mountd/mountd.c (main): When daemonizing, close all fds > 2.

ChangeLog
utils/mountd/mountd.c

index ddee2ebbf9105f5a30b8e45ce9fb57bbed195141..55e2a3024796bcdaea9894732d7c63ef420daae9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2001-10-08  Chip Salzenberg  <chip@pobox.com>
 
 2001-10-08  Chip Salzenberg  <chip@pobox.com>
 
-       * utils/Makefile.in: Remove Makefile in target 'distclean'.
+       * utils/mountd/mountd.c (main): When daemonizing, close all fds > 2.
+       * utils/Makefile.in: Remove old Makefile in target 'distclean'.
        * utils/mountd/mountd.man: Update paths to /var/lib.
        * debian/*: Version 0.3.3-1, with Debian-specific fixes.
 
        * utils/mountd/mountd.man: Update paths to /var/lib.
        * debian/*: Version 0.3.3-1, with Debian-specific fixes.
 
index b5779716148d33eaeb6ec6949e8660f6439aea55..e93f0ba73121d017946697accf2cb98d6d4165be 100644 (file)
@@ -512,11 +512,17 @@ main(int argc, char **argv)
                /* Now we remove ourselves from the foreground.
                   Redirect stdin/stdout/stderr first. */
                {
                /* Now we remove ourselves from the foreground.
                   Redirect stdin/stdout/stderr first. */
                {
-                       int fd = open("/dev/null", O_RDWR);
+                       int fd, fdmax;
+
+                       fd = open("/dev/null", O_RDWR);
                        (void) dup2(fd, 0);
                        (void) dup2(fd, 1);
                        (void) dup2(fd, 2);
                        (void) dup2(fd, 0);
                        (void) dup2(fd, 1);
                        (void) dup2(fd, 2);
-                       if (fd > 2) (void) close(fd);
+
+                       fdmax = sysconf (_SC_OPEN_MAX);
+                       for (fd = 3; fd < fdmax; fd++) {
+                               close (fd);
+                       }
                }
                setsid();
                xlog_background();
                }
                setsid();
                xlog_background();