From 4a86c8193bf05646cdca9faa5253c607d6df5d35 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 20 Jul 2014 21:34:49 -0500 Subject: Isaac Dunham spotted that dhcp was also reimplementing daemon(). --- toys/pending/dhcp.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'toys/pending/dhcp.c') diff --git a/toys/pending/dhcp.c b/toys/pending/dhcp.c index 636746da..bdaefcaa 100644 --- a/toys/pending/dhcp.c +++ b/toys/pending/dhcp.c @@ -314,22 +314,6 @@ static int get_interface( char *interface, int *ifindex, uint32_t *oip, uint8_t return 0; } -static int dhcp_daemon(void) -{ - int fd = open("/dev/null", O_RDWR); - if (fd < 0) fd = xcreate("/", O_RDONLY, 0666); - - if (xfork()) exit(0); - - setsid(); - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); - if (fd > 2) xclose(fd); - - return 0; -} - /* *logs messeges to syslog or console *opening the log is still left with applet. @@ -1368,7 +1352,7 @@ lease_fail: } if (flag_chk(FLAG_b)) { infomsg(infomode, "Lease failed. Going Daemon mode"); - dhcp_daemon(); + daemon(0, 0); if (flag_chk(FLAG_p)) write_pid(TT.pidfile); toys.optflags &= ~FLAG_b; toys.optflags |= FLAG_f; @@ -1505,7 +1489,7 @@ renew_requested: } toys.optflags &= ~FLAG_n; if (!flag_chk(FLAG_f)) { - dhcp_daemon(); + daemon(0, 0); toys.optflags |= FLAG_f; if (flag_chk(FLAG_p)) write_pid(TT.pidfile); } -- cgit v1.2.3