]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Change daemonification code to prolong logging to stderr until dhcpd.conf has been...
authorTed Lemon <source@isc.org>
Sat, 22 Feb 1997 08:49:44 +0000 (08:49 +0000)
committerTed Lemon <source@isc.org>
Sat, 22 Feb 1997 08:49:44 +0000 (08:49 +0000)
dhcpd.c
server/dhcpd.c

diff --git a/dhcpd.c b/dhcpd.c
index 941c4bb0cb3eac8f5b0a85e94d59847f15f78da8..b063c305ac10d2fb5ee681a3b13e8f043f83023f 100644 (file)
--- a/dhcpd.c
+++ b/dhcpd.c
@@ -3,7 +3,7 @@
    DHCP Server Daemon. */
 
 /*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
+ * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char ocopyright[] =
-"$Id: dhcpd.c,v 1.37 1997/02/18 14:30:11 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
+"$Id: dhcpd.c,v 1.38 1997/02/22 08:49:44 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
 #endif
 
 static char copyright[] =
@@ -158,25 +158,13 @@ int main (argc, argv, envp)
                }
        }
 
-       /* If we were requested to log to stdout on the command line,
-          keep doing so; otherwise, stop. */
-       if (log_perror == -1)
-               log_perror = 1;
-       else
-               log_perror = 0;
-
 #ifndef DEBUG
        if (daemon) {
-               /* Become a daemon... */
+               /* First part of becoming a daemon... */
                if ((pid = fork ()) < 0)
                        error ("Can't fork daemon: %m");
                else if (pid)
                        exit (0);
-               /* Become session leader and get pid... */
-               close (0);
-               close (1);
-               close (2);
-               pid = setsid ();
        }
 
        /* Read previous pid file. */
@@ -228,6 +216,21 @@ int main (argc, argv, envp)
        discover_interfaces (1);
 
 #ifndef DEBUG
+       /* If we were requested to log to stdout on the command line,
+          keep doing so; otherwise, stop. */
+       if (log_perror == -1)
+               log_perror = 1;
+       else
+               log_perror = 0;
+
+       if (daemon) {
+               /* Become session leader and get pid... */
+               close (0);
+               close (1);
+               close (2);
+               pid = setsid ();
+       }
+
        /* If we didn't write the pid file earlier because we found a
           process running the logged pid, but we made it to here,
           meaning nothing is listening on the bootp port, then write
@@ -245,7 +248,7 @@ int main (argc, argv, envp)
 #endif /* !DEBUG */
 
        /* Receive packets and dispatch them... */
-       dispatch ();
+       dispatch (1);
 
        /* Not reached */
        return 0;
index 941c4bb0cb3eac8f5b0a85e94d59847f15f78da8..b063c305ac10d2fb5ee681a3b13e8f043f83023f 100644 (file)
@@ -3,7 +3,7 @@
    DHCP Server Daemon. */
 
 /*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
+ * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char ocopyright[] =
-"$Id: dhcpd.c,v 1.37 1997/02/18 14:30:11 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
+"$Id: dhcpd.c,v 1.38 1997/02/22 08:49:44 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
 #endif
 
 static char copyright[] =
@@ -158,25 +158,13 @@ int main (argc, argv, envp)
                }
        }
 
-       /* If we were requested to log to stdout on the command line,
-          keep doing so; otherwise, stop. */
-       if (log_perror == -1)
-               log_perror = 1;
-       else
-               log_perror = 0;
-
 #ifndef DEBUG
        if (daemon) {
-               /* Become a daemon... */
+               /* First part of becoming a daemon... */
                if ((pid = fork ()) < 0)
                        error ("Can't fork daemon: %m");
                else if (pid)
                        exit (0);
-               /* Become session leader and get pid... */
-               close (0);
-               close (1);
-               close (2);
-               pid = setsid ();
        }
 
        /* Read previous pid file. */
@@ -228,6 +216,21 @@ int main (argc, argv, envp)
        discover_interfaces (1);
 
 #ifndef DEBUG
+       /* If we were requested to log to stdout on the command line,
+          keep doing so; otherwise, stop. */
+       if (log_perror == -1)
+               log_perror = 1;
+       else
+               log_perror = 0;
+
+       if (daemon) {
+               /* Become session leader and get pid... */
+               close (0);
+               close (1);
+               close (2);
+               pid = setsid ();
+       }
+
        /* If we didn't write the pid file earlier because we found a
           process running the logged pid, but we made it to here,
           meaning nothing is listening on the bootp port, then write
@@ -245,7 +248,7 @@ int main (argc, argv, envp)
 #endif /* !DEBUG */
 
        /* Receive packets and dispatch them... */
-       dispatch ();
+       dispatch (1);
 
        /* Not reached */
        return 0;