Browse Source

fatal() if daemon() fails, Alexander von Gernler <grunk@pestilenz.org>

OPENBSD_3_7
henning 20 years ago
parent
commit
81a717e58a
1 changed files with 8 additions and 5 deletions
  1. +8
    -5
      src/usr.sbin/ntpd/ntpd.c

+ 8
- 5
src/usr.sbin/ntpd/ntpd.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.c,v 1.27 2004/12/22 16:04:11 henning Exp $ */
/* $OpenBSD: ntpd.c,v 1.28 2005/01/28 12:32:24 henning Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -128,14 +128,15 @@ main(int argc, char *argv[])
if (!conf.settime) { if (!conf.settime) {
log_init(conf.debug); log_init(conf.debug);
if (!conf.debug) if (!conf.debug)
daemon(1, 0);
if (daemon(1, 0))
fatal("daemon");
} else } else
timeout = 15 * 1000; timeout = 15 * 1000;
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_chld) == -1) if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_chld) == -1)
fatal("socketpair"); fatal("socketpair");
/* fork children */
/* fork child process */
chld_pid = ntp_main(pipe_chld, &conf); chld_pid = ntp_main(pipe_chld, &conf);
setproctitle("[priv]"); setproctitle("[priv]");
@ -170,7 +171,8 @@ main(int argc, char *argv[])
timeout = INFTIM; timeout = INFTIM;
log_init(conf.debug); log_init(conf.debug);
if (!conf.debug) if (!conf.debug)
daemon(1, 0);
if (daemon(1, 0))
fatal("daemon");
} }
if (nfds > 0 && (pfd[PFD_PIPE].revents & POLLOUT)) if (nfds > 0 && (pfd[PFD_PIPE].revents & POLLOUT))
@ -274,7 +276,8 @@ dispatch_imsg(struct ntpd_conf *conf)
/* daemonize now */ /* daemonize now */
log_init(conf->debug); log_init(conf->debug);
if (!conf->debug) if (!conf->debug)
daemon(1, 0);
if (daemon(1, 0))
fatal("daemon");
conf->settime = 0; conf->settime = 0;
break; break;
case IMSG_HOST_DNS: case IMSG_HOST_DNS:


Loading…
Cancel
Save