mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-29 13:28:14 +00:00
Rearrange startup code so as to print everything before daemonizing; Don't spew copyright message if quiet is set.
This commit is contained in:
parent
126965a98f
commit
deb0cb72ec
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char ocopyright[] =
|
static char ocopyright[] =
|
||||||
"$Id: dhcpd.c,v 1.43 1997/06/03 01:41:31 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
"$Id: dhcpd.c,v 1.44 1997/10/20 21:38:03 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
@ -73,6 +73,7 @@ int log_perror = -1;
|
|||||||
#else
|
#else
|
||||||
int log_perror = 1;
|
int log_perror = 1;
|
||||||
#endif
|
#endif
|
||||||
|
int quiet_startup;
|
||||||
|
|
||||||
char *path_dhcpd_conf = _PATH_DHCPD_CONF;
|
char *path_dhcpd_conf = _PATH_DHCPD_CONF;
|
||||||
char *path_dhcpd_db = _PATH_DHCPD_DB;
|
char *path_dhcpd_db = _PATH_DHCPD_DB;
|
||||||
@ -108,9 +109,6 @@ int main (argc, argv, envp)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
note (message);
|
|
||||||
note (copyright);
|
|
||||||
note (arr);
|
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (!strcmp (argv [i], "-p")) {
|
if (!strcmp (argv [i], "-p")) {
|
||||||
@ -151,6 +149,8 @@ int main (argc, argv, envp)
|
|||||||
#endif
|
#endif
|
||||||
cftest = 1;
|
cftest = 1;
|
||||||
log_perror = -1;
|
log_perror = -1;
|
||||||
|
} else if (!strcmp (argv [i], "-q")) {
|
||||||
|
quiet_startup = 1;
|
||||||
} else if (argv [i][0] == '-') {
|
} else if (argv [i][0] == '-') {
|
||||||
usage ();
|
usage ();
|
||||||
} else {
|
} else {
|
||||||
@ -168,37 +168,12 @@ int main (argc, argv, envp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DEBUG
|
if (!quiet_startup) {
|
||||||
if (daemon) {
|
note (message);
|
||||||
/* First part of becoming a daemon... */
|
note (copyright);
|
||||||
if ((pid = fork ()) < 0)
|
note (arr);
|
||||||
error ("Can't fork daemon: %m");
|
|
||||||
else if (pid)
|
|
||||||
exit (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read previous pid file. */
|
|
||||||
if ((i = open (path_dhcpd_pid, O_RDONLY)) >= 0) {
|
|
||||||
status = read (i, pbuf, (sizeof pbuf) - 1);
|
|
||||||
close (i);
|
|
||||||
pbuf [status] = 0;
|
|
||||||
pid = atoi (pbuf);
|
|
||||||
|
|
||||||
/* If the previous server process is not still running,
|
|
||||||
write a new pid file immediately. */
|
|
||||||
if (pid && kill (pid, 0) < 0) {
|
|
||||||
unlink (path_dhcpd_pid);
|
|
||||||
if ((i = open (path_dhcpd_pid,
|
|
||||||
O_WRONLY | O_CREAT, 0640)) >= 0) {
|
|
||||||
sprintf (pbuf, "%d\n", (int)getpid ());
|
|
||||||
write (i, pbuf, strlen (pbuf));
|
|
||||||
close (i);
|
|
||||||
pidfilewritten = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* !DEBUG */
|
|
||||||
|
|
||||||
/* Default to the DHCP/BOOTP port. */
|
/* Default to the DHCP/BOOTP port. */
|
||||||
if (!local_port)
|
if (!local_port)
|
||||||
{
|
{
|
||||||
@ -238,6 +213,35 @@ int main (argc, argv, envp)
|
|||||||
icmp_startup (1, lease_pinged);
|
icmp_startup (1, lease_pinged);
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
|
if (daemon) {
|
||||||
|
/* First part of becoming a daemon... */
|
||||||
|
if ((pid = fork ()) < 0)
|
||||||
|
error ("Can't fork daemon: %m");
|
||||||
|
else if (pid)
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read previous pid file. */
|
||||||
|
if ((i = open (path_dhcpd_pid, O_RDONLY)) >= 0) {
|
||||||
|
status = read (i, pbuf, (sizeof pbuf) - 1);
|
||||||
|
close (i);
|
||||||
|
pbuf [status] = 0;
|
||||||
|
pid = atoi (pbuf);
|
||||||
|
|
||||||
|
/* If the previous server process is not still running,
|
||||||
|
write a new pid file immediately. */
|
||||||
|
if (pid && kill (pid, 0) < 0) {
|
||||||
|
unlink (path_dhcpd_pid);
|
||||||
|
if ((i = open (path_dhcpd_pid,
|
||||||
|
O_WRONLY | O_CREAT, 0640)) >= 0) {
|
||||||
|
sprintf (pbuf, "%d\n", (int)getpid ());
|
||||||
|
write (i, pbuf, strlen (pbuf));
|
||||||
|
close (i);
|
||||||
|
pidfilewritten = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If we were requested to log to stdout on the command line,
|
/* If we were requested to log to stdout on the command line,
|
||||||
keep doing so; otherwise, stop. */
|
keep doing so; otherwise, stop. */
|
||||||
if (log_perror == -1)
|
if (log_perror == -1)
|
||||||
@ -283,6 +287,10 @@ int main (argc, argv, envp)
|
|||||||
|
|
||||||
static void usage ()
|
static void usage ()
|
||||||
{
|
{
|
||||||
|
note (message);
|
||||||
|
note (copyright);
|
||||||
|
note (arr);
|
||||||
|
|
||||||
error ("Usage: dhcpd [-p <UDP port #>] [-d] [-f] [-cf config-file]%s",
|
error ("Usage: dhcpd [-p <UDP port #>] [-d] [-f] [-cf config-file]%s",
|
||||||
"\n [-lf lease-file] [if0 [...ifN]]");
|
"\n [-lf lease-file] [if0 [...ifN]]");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user