From owner-freebsd-questions@FreeBSD.ORG Wed Dec 4 23:01:31 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 965A9255 for ; Wed, 4 Dec 2013 23:01:31 +0000 (UTC) Received: from be-well.ilk.org (be-well.ilk.org [23.30.133.173]) by mx1.freebsd.org (Postfix) with ESMTP id 6B50C1838 for ; Wed, 4 Dec 2013 23:01:31 +0000 (UTC) Received: from lowell-desk.lan (lowell-desk.lan [172.30.250.41]) by be-well.ilk.org (Postfix) with ESMTP id B308733C1D; Wed, 4 Dec 2013 18:01:25 -0500 (EST) Received: by lowell-desk.lan (Postfix, from userid 1147) id 7676139830; Wed, 4 Dec 2013 18:01:24 -0500 (EST) From: Lowell Gilbert To: Unga Subject: Re: Having every daemon put itself into the background is bad software design References: <1386092314.98211.YahooMailNeo@web161904.mail.bf1.yahoo.com> Date: Wed, 04 Dec 2013 18:01:23 -0500 In-Reply-To: <1386092314.98211.YahooMailNeo@web161904.mail.bf1.yahoo.com> (Unga's message of "Tue, 3 Dec 2013 09:38:34 -0800 (PST)") Message-ID: <444n6ofcfw.fsf@lowell-desk.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Cc: "freebsd-questions@freebsd.org" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Dec 2013 23:01:31 -0000 Unga writes: > Dr. D. J. Bernstein says "Having every daemon put itself into the background > is bad software design." in http://cr.yp.to/daemontools/faq/create.html . You have to realize that in saying that, DJB is using his own definitions of multiple terms, subtly different from the usual senses of those words. You have to be aware that you're dealing with someone who goes his own way in order to make progress with his approaches to things. > That is, is it possible to write a daemon to run in foreground and automatically started at system boot up (via /etc/rc.conf)? Note that rc.conf doesn't actually do anything by itself. It contains only settings that other scripts will use for configuring various settings. I will assume that when you say "rc.conf" you mean the whole system, with scripts in rc.d and so forth. In which case, the answer is still "not directly"; if you want to, you would install daemontools and use that to start the program in question. > Does he means after fork(2), the parent continue to run? Can such a program started via the /etc/rc.conf without a terminal attached? No. As I understand it, the idea is that there's no fork needed at all, because the program invocation blocks and remains the process leader. > Btw, I got in to this problem by trying to use DJB's daemontools to > supervise my server running on FreeBSD. But it creates zombie > processes and spawn quite fast. In my daemons, after fork(2), parent > returns. To be honest, I suspect you don't really have the background to understand what daemontools is supposed to do for you. Most daemons *only* fork in order to background themselves. Good luck.