changeset 1396:e0c9c5424864 draft

Isaac Dunham spotted that dhcp was also reimplementing daemon().
author Rob Landley <rob@landley.net>
date Sun, 20 Jul 2014 21:34:49 -0500
parents 5149632b0d07
children 3fb99aaae28b
files toys/pending/dhcp.c
diffstat 1 files changed, 2 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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);
           }