From owner-freebsd-questions@FreeBSD.ORG Thu Dec 5 15:13:03 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D44237EC for ; Thu, 5 Dec 2013 15:13:03 +0000 (UTC) Received: from mail-wi0-x22a.google.com (mail-wi0-x22a.google.com [IPv6:2a00:1450:400c:c05::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6CF6B1337 for ; Thu, 5 Dec 2013 15:13:03 +0000 (UTC) Received: by mail-wi0-f170.google.com with SMTP id hq4so1009763wib.5 for ; Thu, 05 Dec 2013 07:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=zWN8LMLRAnr77Q3eAT5yXhZdVfAhJOhgoG/0sMl6C6k=; b=h+/f0dMNBYsrHFohJI3sARZ43ljmnm2Otd6yuEmPd312n50fiWB8pfIPLhV6Ece9O7 ZFkO9CPMCYzE7VgY26a+O49LyrqDejCmXETI6BMN4b5IvcDkS02bCX7uUspJFD/k+i97 ngFkrZVs/YcwCv/8pbKXe+OhNNdY4IgSwDN5DYSWZuVik6rqJNGVh5OHqizDXFClRVpp Jinb4ZF/Uoyp4+daKMB8c6aMJ/jnSN5ifzhIRf2AiXS8S7aE58aI+32toGn2VhrwLOf6 RYFg62RtSJYaUx/SsQnY122KqTq7Bv79UyRUL5/L6Crzi51cgpPi9JO/oRMxJ77wtRrv TpBA== MIME-Version: 1.0 X-Received: by 10.180.183.72 with SMTP id ek8mr12457685wic.49.1386256381809; Thu, 05 Dec 2013 07:13:01 -0800 (PST) Sender: fluca1978@gmail.com Received: by 10.194.44.6 with HTTP; Thu, 5 Dec 2013 07:13:01 -0800 (PST) In-Reply-To: <1386092314.98211.YahooMailNeo@web161904.mail.bf1.yahoo.com> References: <1386092314.98211.YahooMailNeo@web161904.mail.bf1.yahoo.com> Date: Thu, 5 Dec 2013 16:13:01 +0100 X-Google-Sender-Auth: ETbMoqu8Ie-qMd7IWhwM15sBg0o Message-ID: Subject: Re: Having every daemon put itself into the background is bad software design From: Luca Ferrari To: Unga Content-Type: text/plain; charset=ISO-8859-1 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: Thu, 05 Dec 2013 15:13:03 -0000 On Tue, Dec 3, 2013 at 6:38 PM, Unga 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