diff options
author | pjd <pjd@FreeBSD.org> | 2010-08-27 14:35:39 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2010-08-27 14:35:39 +0000 |
commit | dd3961e615cb3f103c9d0bd0c4c18e1cb3773869 (patch) | |
tree | fdf23a2087035b4d0a381cdefe7d3aae126c2cbe /sbin/hastd | |
parent | ac5c9c92167fc3e4144590f6f3b82aac67bdb176 (diff) | |
download | FreeBSD-src-dd3961e615cb3f103c9d0bd0c4c18e1cb3773869.zip FreeBSD-src-dd3961e615cb3f103c9d0bd0c4c18e1cb3773869.tar.gz |
When logging to stdout/stderr don't close those descriptors after fork().
MFC after: 2 weeks
Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com
Diffstat (limited to 'sbin/hastd')
-rw-r--r-- | sbin/hastd/hooks.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sbin/hastd/hooks.c b/sbin/hastd/hooks.c index 1fdeb75..617e051 100644 --- a/sbin/hastd/hooks.c +++ b/sbin/hastd/hooks.c @@ -61,8 +61,21 @@ descriptors(void) pjdlog_errno(LOG_WARNING, "sysconf(_SC_OPEN_MAX) failed"); maxfd = 1024; } - for (fd = 0; fd <= maxfd; fd++) - close(fd); + for (fd = 0; fd <= maxfd; fd++) { + switch (fd) { + case STDIN_FILENO: + case STDOUT_FILENO: + case STDERR_FILENO: + if (pjdlog_mode_get() == PJDLOG_MODE_STD) + break; + /* FALLTHROUGH */ + default: + close(fd); + break; + } + } + if (pjdlog_mode_get() == PJDLOG_MODE_STD) + return; /* * Redirect stdin, stdout and stderr to /dev/null. */ |