diff options
author | trasz <trasz@FreeBSD.org> | 2014-03-25 12:00:05 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2014-03-25 12:00:05 +0000 |
commit | cf1ffe3cac870ee6ad26c728c25900ce607b3839 (patch) | |
tree | e551600eac3cd9f096c402d965d4664f8d000ef7 | |
parent | 930438f7d5ffcf8c643bbd387b7f80615f3fdaa9 (diff) | |
download | FreeBSD-src-cf1ffe3cac870ee6ad26c728c25900ce607b3839.zip FreeBSD-src-cf1ffe3cac870ee6ad26c728c25900ce607b3839.tar.gz |
MFC r261753:
Daemonize after applying configuration, not before, so that
any problems - including "daemon already running" - are visible
on the terminal and not just in logs.
Sponsored by: The FreeBSD Foundation
-rw-r--r-- | usr.sbin/ctld/ctld.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c index 4088811..6051348 100644 --- a/usr.sbin/ctld/ctld.c +++ b/usr.sbin/ctld/ctld.c @@ -1644,14 +1644,6 @@ main(int argc, char **argv) newconf->conf_debug = debug; } - if (dont_daemonize == false) { - if (daemon(0, 0) == -1) { - log_warn("cannot daemonize"); - pidfile_remove(newconf->conf_pidfh); - exit(1); - } - } - #ifdef ICL_KERNEL_PROXY log_debugx("enabling CTL iSCSI port"); error = kernel_port_on(); @@ -1674,6 +1666,15 @@ main(int argc, char **argv) log_errx(1, "failed to enable CTL iSCSI port, exiting"); #endif + if (dont_daemonize == false) { + log_debugx("daemonizing"); + if (daemon(0, 0) == -1) { + log_warn("cannot daemonize"); + pidfile_remove(newconf->conf_pidfh); + exit(1); + } + } + for (;;) { main_loop(newconf, dont_daemonize); if (sighup_received) { |