summaryrefslogtreecommitdiffstats
path: root/usr.sbin/rtsold
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2003-08-14 18:13:34 +0000
committerume <ume@FreeBSD.org>2003-08-14 18:13:34 +0000
commite9eb0e8fd52654b2186fd35107e2e980bad3dba4 (patch)
treed691cd82b419d76db236769949664a7a17327a02 /usr.sbin/rtsold
parent41379bc0db8dbf63c8b1eda44626da4d537672b4 (diff)
downloadFreeBSD-src-e9eb0e8fd52654b2186fd35107e2e980bad3dba4.zip
FreeBSD-src-e9eb0e8fd52654b2186fd35107e2e980bad3dba4.tar.gz
daemon() has to be called prior to file descriptor setups
(otherwise file descriptors could be closed mistakenly) Obtained from: KAME MFC after: 1 week
Diffstat (limited to 'usr.sbin/rtsold')
-rw-r--r--usr.sbin/rtsold/rtsold.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c
index 36ecb30..d6891e7 100644
--- a/usr.sbin/rtsold/rtsold.c
+++ b/usr.sbin/rtsold/rtsold.c
@@ -229,18 +229,23 @@ main(argc, argv)
/* initialization to dump internal status to a file */
signal(SIGUSR1, rtsold_set_dump_file);
+ if (!fflag)
+ daemon(0, 0); /* act as a daemon */
+
/*
* Open a socket for sending RS and receiving RA.
* This should be done before calling ifinit(), since the function
* uses the socket.
*/
if ((s = sockopen()) < 0) {
- errx(1, "failed to open a socket");
+ warnmsg(LOG_ERR, __func__, "failed to open a socket");
+ exit(1);
/*NOTREACHED*/
}
maxfd = s;
if ((rtsock = rtsock_open()) < 0) {
- errx(1, "failed to open a socket");
+ warnmsg(LOG_ERR, __func__, "failed to open a socket");
+ exit(1);
/*NOTREACHED*/
}
if (rtsock > maxfd)
@@ -258,12 +263,16 @@ main(argc, argv)
/* configuration per interface */
if (ifinit()) {
- errx(1, "failed to initilizatoin interfaces");
+ warnmsg(LOG_ERR, __func__,
+ "failed to initilizatoin interfaces");
+ exit(1);
/*NOTREACHED*/
}
while (argc--) {
if (ifconfig(*argv)) {
- errx(1, "failed to initialize %s", *argv);
+ warnmsg(LOG_ERR, __func__,
+ "failed to initialize %s", *argv);
+ exit(1);
/*NOTREACHED*/
}
argv++;
@@ -271,13 +280,12 @@ main(argc, argv)
/* setup for probing default routers */
if (probe_init()) {
- errx(1, "failed to setup for probing routers");
+ warnmsg(LOG_ERR, __func__,
+ "failed to setup for probing routers");
+ exit(1);
/*NOTREACHED*/
}
- if (!fflag)
- daemon(0, 0); /* act as a daemon */
-
/* dump the current pid */
if (!once) {
pid_t pid = getpid();
OpenPOWER on IntegriCloud