Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Dec 2013 16:13:01 +0100
From:      Luca Ferrari <fluca1978@infinito.it>
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:  <CAKoxK+6jredtY+9qXer5EGxmfXs3FUfw246jKnOAS99JLi-q5Q@mail.gmail.com>
In-Reply-To: <1386092314.98211.YahooMailNeo@web161904.mail.bf1.yahoo.com>
References:  <1386092314.98211.YahooMailNeo@web161904.mail.bf1.yahoo.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Tue, Dec 3, 2013 at 6:38 PM, Unga <unga888@yahoo.com> wrote:

> 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 .
>

Even having to configure or send to background every daemon by your
own is a bad design. I suspect the key point here is that every
daemon, before going to the background, should allow the admin to keep
it on the foregorund for very specific debugging purposes.


> Can someone provide a sample in C?
>

Yes:

int main( int argc, char** argv ){
    for ( ;; )
      printf( "\nI'm still here!" );
}

> 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?


After fork(2) the parent continues to run, effectively the parent and
the child run. What normally happens in a shell is that when you use
"&" to put a command in background the shell do not waits and continue
running on its own life.



> 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.

I don't have any idea what you are doing, since it is not clear what
your daemons are doing....

Luca



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?CAKoxK+6jredtY+9qXer5EGxmfXs3FUfw246jKnOAS99JLi-q5Q>