# HG changeset patch # User Rob Landley # Date 1405910089 18000 # Node ID e0c9c5424864b48e00cb4d29affa631d8efece9f # Parent 5149632b0d07e0f1caac7ef70864985ceea5a33b Isaac Dunham spotted that dhcp was also reimplementing daemon(). diff -r 5149632b0d07 -r e0c9c5424864 toys/pending/dhcp.c --- a/toys/pending/dhcp.c Sun Jul 20 16:34:36 2014 -0500 +++ b/toys/pending/dhcp.c Sun Jul 20 21:34:49 2014 -0500 @@ -314,22 +314,6 @@ 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 @@ } 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 @@ } 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); }