Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Dec 2013 09:38:34 -0800 (PST)
From:      Unga <unga888@yahoo.com>
To:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Having every daemon put itself into the background is bad software design
Message-ID:  <1386092314.98211.YahooMailNeo@web161904.mail.bf1.yahoo.com>

next in thread | raw e-mail | index | archive | help
Hi

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 .

That is, is it possible to write a daemon to run in foreground and automatically started at system boot up (via /etc/rc.conf)?

Can someone provide a sample in C?

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?

Any idea?

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.

Best regards
Unga
From owner-freebsd-questions@FreeBSD.ORG  Tue Dec  3 17:46:41 2013
Return-Path: <owner-freebsd-questions@FreeBSD.ORG>
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 56B11729
 for <freebsd-questions@freebsd.org>; Tue,  3 Dec 2013 17:46:41 +0000 (UTC)
Received: from mail-oa0-x22e.google.com (mail-oa0-x22e.google.com
 [IPv6:2607:f8b0:4003:c02::22e])
 (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits))
 (No client certificate requested)
 by mx1.freebsd.org (Postfix) with ESMTPS id 209CE1511
 for <freebsd-questions@freebsd.org>; Tue,  3 Dec 2013 17:46:41 +0000 (UTC)
Received: by mail-oa0-f46.google.com with SMTP id o6so15189948oag.5
 for <freebsd-questions@freebsd.org>; Tue, 03 Dec 2013 09:46:40 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:in-reply-to:references:date:message-id:subject:from:to
 :content-type; bh=WFIkhmARo2Mh/vw7pxXapoNxJhYSBR+XV/zBMbPrQ3U=;
 b=s8CXV2fl7nIbXKM4OKCIcSOZFr4MKfWjNQrBEJKxnftr/vKgouccFqY441t/HEhlfo
 5s7XihQtsFgL/VbXyA5uSZe/pLXPikwzr5SZ3FcBDwyUrLfFqvgb+n08nhuJi2V3qfH/
 9IMV7VaPqYwLeAIYzpLLx+HvIRP9q/ubBkJvXX60LINCTqOecQ/hGCK0V/T09DbmezCK
 4jDVrgSfSVG8y9CFK4XKI70+Bye22Ge9V5NHVWvQFcJmV++vPh3tp4YRT7kG31sANDqg
 i7BjvLjUzAHtWKhS3RNFNwesYDc/pcxQNjYbcEZ25GGAuEZ1wV/kkxhr19PFF75nxXFt
 6RFw==
MIME-Version: 1.0
X-Received: by 10.60.134.14 with SMTP id pg14mr1920419oeb.66.1386092800196;
 Tue, 03 Dec 2013 09:46:40 -0800 (PST)
Received: by 10.182.139.9 with HTTP; Tue, 3 Dec 2013 09:46:40 -0800 (PST)
In-Reply-To: <44r49tg8uv.fsf@lowell-desk.lan>
References: <CACxAsm7khsW9Gt4uC6kHGvaX5-LZ=iMw_7qaw2=u63DvSDJKBQ@mail.gmail.com>
 <44r49tg8uv.fsf@lowell-desk.lan>
Date: Wed, 4 Dec 2013 02:46:40 +0900
Message-ID: <CACxAsm6fEbEduYoS=VVwXxV_YonjpHrbhdMiD_HO-bxaef+Z2A@mail.gmail.com>
Subject: Re: local ports collection
From: till plewe <till.plewe@gmail.com>
To: FreeBSD-Questions <freebsd-questions@freebsd.org>
Content-Type: text/plain; charset=UTF-8
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions/>;
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 03 Dec 2013 17:46:41 -0000

Thanks for the answer. DESTDIR was supposed to be DISTDIR (typo).
Setting SU_CMD was the hint I needed. Now it seems adjusting ldconfig
is the only thing left to do. pkg installed without problems.

On Wed, Dec 4, 2013 at 2:08 AM, Lowell Gilbert
<freebsd-questions-local@be-well.ilk.org> wrote:
> till plewe <till.plewe@gmail.com> writes:
>
>> I would like to use the ports tree to install and manage packages inside my
>> home directory. I tried setting:
>>
>> PKG_DBDIR,PREFIX,PORTSDIR,LOCALBASE,PORT_DBDIR,DESTDIR
>
> Don't use DESTDIR; it doesn't do what you think it does.
> [What did you think it did anyway, and why?]
>
>> to directories within my home directory but then I get error messages like
>>
>> $ make build
>> ===>  Creating some important subdirectories
>> mount_nullfs: Operation not permitted
>>
>> when trying to build/install ports.
>>
>> Any suggestions on how to use ports completely avoiding root?
>> (I rented space on a server and have permission to install binaries
>> but do not have root access)
>
> You'll probably have to change SU_CMD as well.
> Something like "su $USER -c" should do it.
> And you may need to bootstrap the pkg(8) command somehow.
>
> Good luck.



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