From: Ted Lemon Date: Sat, 22 Feb 1997 08:49:44 +0000 (+0000) Subject: Change daemonification code to prolong logging to stderr until dhcpd.conf has been... X-Git-Tag: DHCP_970222~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31755be8f76f655b1a1704ffc32655bd078ab827;p=thirdparty%2Fdhcp.git Change daemonification code to prolong logging to stderr until dhcpd.conf has been parsed.; dispatch takes an argument. --- diff --git a/dhcpd.c b/dhcpd.c index 941c4bb0c..b063c305a 100644 --- 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; diff --git a/server/dhcpd.c b/server/dhcpd.c index 941c4bb0c..b063c305a 100644 --- a/server/dhcpd.c +++ b/server/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;