diff options
author | chip <chip> | 2001-10-08 22:57:58 +0000 |
---|---|---|
committer | chip <chip> | 2001-10-08 22:57:58 +0000 |
commit | 47e5725d85dc2fed09c584d5de16afbe1b434887 (patch) | |
tree | 3a5b2788b9934844b32236e3f3c5d0e065f540ef | |
parent | 48549afe6f5d5b67b4132e9551d62b1a864d672e (diff) | |
download | nfs-utils-47e5725d85dc2fed09c584d5de16afbe1b434887.tar.gz nfs-utils-47e5725d85dc2fed09c584d5de16afbe1b434887.tar.xz nfs-utils-47e5725d85dc2fed09c584d5de16afbe1b434887.zip |
2001-10-08 Chip Salzenberg <chip@pobox.com>
* utils/mountd/mountd.c (main): When daemonizing, close all fds > 2.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | utils/mountd/mountd.c | 10 |
2 files changed, 10 insertions, 3 deletions
@@ -1,6 +1,7 @@ 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. diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index b577971..e93f0ba 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -512,11 +512,17 @@ main(int argc, char **argv) /* 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); - if (fd > 2) (void) close(fd); + + fdmax = sysconf (_SC_OPEN_MAX); + for (fd = 3; fd < fdmax; fd++) { + close (fd); + } } setsid(); xlog_background(); |