ia64/xen-unstable

changeset 15698:07364f8574b8

xenstore: Redirect stdin/stdout/stderr to /dev/null.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Aug 01 19:34:56 2007 +0100 (2007-08-01)
parents f343d3c16dcc
children e0b424bc9572
files tools/xenstore/xenstored_core.c
line diff
     1.1 --- a/tools/xenstore/xenstored_core.c	Wed Aug 01 19:17:08 2007 +0100
     1.2 +++ b/tools/xenstore/xenstored_core.c	Wed Aug 01 19:34:56 2007 +0100
     1.3 @@ -1880,10 +1880,14 @@ int main(int argc, char *argv[])
     1.4  
     1.5  	/* close stdin/stdout now we're ready to accept connections */
     1.6  	if (dofork) {
     1.7 -		close(STDIN_FILENO);
     1.8 -		close(STDOUT_FILENO);
     1.9 -		close(STDERR_FILENO);
    1.10 -		xprintf = trace; /* xprintf() must not use stderr */
    1.11 +		int devnull = open("/dev/null", O_RDWR);
    1.12 +		if (devnull == -1)
    1.13 +			barf_perror("Could not open /dev/null\n");
    1.14 +		close(STDIN_FILENO);  dup2(STDIN_FILENO, devnull);
    1.15 +		close(STDOUT_FILENO); dup2(STDOUT_FILENO, devnull);
    1.16 +		close(STDERR_FILENO); dup2(STDERR_FILENO, devnull);
    1.17 +		close(devnull);
    1.18 +		xprintf = trace;
    1.19  	}
    1.20  
    1.21  	signal(SIGHUP, trigger_reopen_log);