Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Dec 2013 18:01:23 -0500
From:      Lowell Gilbert <freebsd-questions-local@be-well.ilk.org>
To:        Unga <unga888@yahoo.com>
Cc:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: Having every daemon put itself into the background is bad software design
Message-ID:  <444n6ofcfw.fsf@lowell-desk.lan>
In-Reply-To: <1386092314.98211.YahooMailNeo@web161904.mail.bf1.yahoo.com> (Unga's message of "Tue, 3 Dec 2013 09:38:34 -0800 (PST)")
References:  <1386092314.98211.YahooMailNeo@web161904.mail.bf1.yahoo.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
Unga <unga888@yahoo.com> 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.



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?444n6ofcfw.fsf>