summaryrefslogtreecommitdiff
path: root/usr.sbin/route6d/route6d.c
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-01-11 03:51:09 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-01-11 03:51:09 +0000
commit1e286bf79bcff9bd04964a6d4b7b0773a1e7afa6 (patch)
tree0fbc05365ca874a6326cdf81a3b8732218b12bfa /usr.sbin/route6d/route6d.c
parent9f1463a8c6c1b28e4c9707469ac02a119f30e7d6 (diff)
call daemon(3) prior to socket setups to avoid file descriptor close mistakes.
noted by markus, sync with kame
Diffstat (limited to 'usr.sbin/route6d/route6d.c')
-rw-r--r--usr.sbin/route6d/route6d.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/usr.sbin/route6d/route6d.c b/usr.sbin/route6d/route6d.c
index 6e110d3ddaa..48ed2e12590 100644
--- a/usr.sbin/route6d/route6d.c
+++ b/usr.sbin/route6d/route6d.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route6d.c,v 1.21 2001/12/01 23:27:23 miod Exp $ */
+/* $OpenBSD: route6d.c,v 1.22 2002/01/11 03:51:08 itojun Exp $ */
/* $KAME: route6d.c,v 1.73 2001/09/05 01:12:34 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#if 0
-static char _rcsid[] = "$OpenBSD: route6d.c,v 1.21 2001/12/01 23:27:23 miod Exp $";
+static char _rcsid[] = "$OpenBSD: route6d.c,v 1.22 2002/01/11 03:51:08 itojun Exp $";
#endif
#include <stdio.h>
@@ -349,6 +349,14 @@ main(argc, argv)
nflag = 1;
fprintf(stderr, "No kernel update is allowed\n");
}
+
+ if (dflag == 0) {
+ if (daemon(0, 0) < 0) {
+ fatal("daemon");
+ /*NOTREACHED*/
+ }
+ }
+
openlog(progname, LOG_NDELAY|LOG_PID, LOG_DAEMON);
logopened++;
@@ -384,21 +392,6 @@ main(argc, argv)
if (dflag)
ifrtdump(0);
- if (dflag == 0) {
-#if 1
- if (daemon(0, 0) < 0) {
- fatal("daemon");
- /*NOTREACHED*/
- }
-#else
- if (fork())
- exit(0);
- if (setsid() < 0) {
- fatal("setid");
- /*NOTREACHED*/
- }
-#endif
- }
pidfile(NULL);
if ((ripbuf = (struct rip6 *)malloc(RIP6_MAXMTU)) == NULL) {