aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2000-03-20 16:16:27 +0000
committerBill Nottingham <notting@redhat.com>2000-03-20 16:16:27 +0000
commitf46ccc3e3e2a55c2fc61a250396535ed1dccdf60 (patch)
tree98dd37406ee5ef3041fc2a8dabd5c6cf847bda3d
parent050d2a03d5fa4b091832c034c953a25b1462adfc (diff)
downloadinitscripts-f46ccc3e3e2a55c2fc61a250396535ed1dccdf60.tar
initscripts-f46ccc3e3e2a55c2fc61a250396535ed1dccdf60.tar.gz
initscripts-f46ccc3e3e2a55c2fc61a250396535ed1dccdf60.tar.bz2
initscripts-f46ccc3e3e2a55c2fc61a250396535ed1dccdf60.tar.xz
initscripts-f46ccc3e3e2a55c2fc61a250396535ed1dccdf60.zip
open /dev/null for child process instead of closing fds 0,1,2
-rw-r--r--src/ppp-watch.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ppp-watch.c b/src/ppp-watch.c
index 645034c3..e97c3acb 100644
--- a/src/ppp-watch.c
+++ b/src/ppp-watch.c
@@ -166,12 +166,18 @@ detach(int now, int parentExitCode, char *device) {
exit(exitCode);
} else {
+ int devnull;
+
/* child process */
close (pipeArray[0]);
/* become a daemon */
- close (0);
- close (1);
- close (2);
+ devnull = open("/dev/null", O_RDONLY);
+ dup2(devnull,0);
+ close(devnull);
+ devnull = open("/dev/null", O_WRONLY);
+ dup2(devnull,1);
+ dup2(devnull,2);
+ close(devnull);
setsid();
setpgid(0, 0);
}