diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-08-01 19:34:56 +0100 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-08-01 19:34:56 +0100 |
commit | 140b3cd6278a9f663a4fe64b38936d60791c18c9 (patch) | |
tree | 985b5eba6c7dc37401018175247787bfda3d1655 /tools | |
parent | 79a18447fe70c67d682bcf585c2234efca25f46a (diff) | |
download | xen-140b3cd6278a9f663a4fe64b38936d60791c18c9.tar.gz xen-140b3cd6278a9f663a4fe64b38936d60791c18c9.tar.bz2 xen-140b3cd6278a9f663a4fe64b38936d60791c18c9.zip |
xenstore: Redirect stdin/stdout/stderr to /dev/null.
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/xenstore/xenstored_core.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index a969bcff56..e68004ad05 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1880,10 +1880,14 @@ int main(int argc, char *argv[]) /* close stdin/stdout now we're ready to accept connections */ if (dofork) { - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); - xprintf = trace; /* xprintf() must not use stderr */ + int devnull = open("/dev/null", O_RDWR); + if (devnull == -1) + barf_perror("Could not open /dev/null\n"); + close(STDIN_FILENO); dup2(STDIN_FILENO, devnull); + close(STDOUT_FILENO); dup2(STDOUT_FILENO, devnull); + close(STDERR_FILENO); dup2(STDERR_FILENO, devnull); + close(devnull); + xprintf = trace; } signal(SIGHUP, trigger_reopen_log); |