From bce289aede70790468b2bfcf4d7ac33e8903c03e Mon Sep 17 00:00:00 2001 From: pooka Date: Sun, 6 Feb 2011 19:00:53 +0000 Subject: Call daemon() later to make sure there is a listening socket by the time the foreground process exits. discussed with mrg. --- libexec/httpd/daemon-bozo.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libexec') diff --git a/libexec/httpd/daemon-bozo.c b/libexec/httpd/daemon-bozo.c index bf95e0e5160..d65b19b858f 100644 --- a/libexec/httpd/daemon-bozo.c +++ b/libexec/httpd/daemon-bozo.c @@ -1,4 +1,4 @@ -/* $NetBSD: daemon-bozo.c,v 1.11 2010/06/22 05:24:12 mrg Exp $ */ +/* $NetBSD: daemon-bozo.c,v 1.12 2011/02/06 19:00:53 pooka Exp $ */ /* $eterna: daemon-bozo.c,v 1.22 2010/06/21 06:45:45 mrg Exp $ */ @@ -79,12 +79,7 @@ bozo_daemon_init(bozohttpd_t *httpd) if (!httpd->background) return; - if (httpd->foreground == 0) - daemon(1, 0); - portnum = (httpd->bindport) ? httpd->bindport : "http"; - bozo_warn(httpd, "started in daemon mode as `%s' port `%s' root `%s'", - httpd->virthostname, portnum, httpd->slashdir); memset(&h, 0, sizeof(h)); h.ai_family = PF_UNSPEC; @@ -121,6 +116,12 @@ bozo_daemon_init(bozohttpd_t *httpd) httpd->nsock = i; freeaddrinfo(r0); + if (httpd->foreground == 0) + daemon(1, 0); + + bozo_warn(httpd, "started in daemon mode as `%s' port `%s' root `%s'", + httpd->virthostname, portnum, httpd->slashdir); + signal(SIGCHLD, sigchild); } -- cgit