[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xenstore: Redirect stdin/stdout/stderr to /dev/null.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1185993296 -3600
# Node ID 07364f8574b8fa9cb84d446c83fb13deee24fd81
# Parent  f343d3c16dccbe6215bddcd04a0524ab06b4cab0
xenstore: Redirect stdin/stdout/stderr to /dev/null.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/xenstore/xenstored_core.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff -r f343d3c16dcc -r 07364f8574b8 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Wed Aug 01 19:17:08 2007 +0100
+++ b/tools/xenstore/xenstored_core.c   Wed Aug 01 19:34:56 2007 +0100
@@ -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);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.