aboutsummaryrefslogtreecommitdiff
path: root/sbin/hastd/hooks.c
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2010-08-27 14:35:39 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2010-08-27 14:35:39 +0000
commite64887c4d6e714b07a3706210700682925cd393a (patch)
treefdf23a2087035b4d0a381cdefe7d3aae126c2cbe /sbin/hastd/hooks.c
parent3f828c18e53c8f171c0a7385dfda6f3ffcf5e95a (diff)
downloadsrc-e64887c4d6e714b07a3706210700682925cd393a.tar.gz
src-e64887c4d6e714b07a3706210700682925cd393a.zip
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
Notes
Notes: svn path=/head/; revision=211884
Diffstat (limited to 'sbin/hastd/hooks.c')
-rw-r--r--sbin/hastd/hooks.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sbin/hastd/hooks.c b/sbin/hastd/hooks.c
index 1fdeb7500859..617e05143f28 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.
*/