diff options
Diffstat (limited to 'sdpd/main.c')
| -rw-r--r-- | sdpd/main.c | 13 | 
1 files changed, 11 insertions, 2 deletions
| diff --git a/sdpd/main.c b/sdpd/main.c index dd725c81..685ffa8b 100644 --- a/sdpd/main.c +++ b/sdpd/main.c @@ -30,6 +30,7 @@  #include <stdio.h>  #include <errno.h> +#include <fcntl.h>  #include <unistd.h>  #include <stdlib.h>  #include <signal.h> @@ -301,8 +302,16 @@ static int become_daemon(void)  			return 0;  		setsid();  	} -	for (fd = 0; fd < 3; fd++) -		close(fd); + +	fd = open("/dev/null", O_RDWR); +	if (fd != -1) { +		dup2(fd, STDIN_FILENO); +		dup2(fd, STDOUT_FILENO); +		dup2(fd, STDERR_FILENO); + +		if (fd > STDERR_FILENO) +			close(fd); +	}  	chdir("/");  	return 1; | 
