Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Mar 2014 12:00:05 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r263719 - stable/10/usr.sbin/ctld
Message-ID:  <201403251200.s2PC05Oa066662@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Tue Mar 25 12:00:05 2014
New Revision: 263719
URL: http://svnweb.freebsd.org/changeset/base/263719

Log:
  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

Modified:
  stable/10/usr.sbin/ctld/ctld.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/ctld/ctld.c
==============================================================================
--- stable/10/usr.sbin/ctld/ctld.c	Tue Mar 25 11:58:24 2014	(r263718)
+++ stable/10/usr.sbin/ctld/ctld.c	Tue Mar 25 12:00:05 2014	(r263719)
@@ -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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403251200.s2PC05Oa066662>