From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 20 01:49:25 2005 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A882616A41F for ; Thu, 20 Oct 2005 01:49:25 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 59D0F43D66 for ; Thu, 20 Oct 2005 01:49:25 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id 2A47E46B7F; Wed, 19 Oct 2005 21:49:24 -0400 (EDT) Date: Thu, 20 Oct 2005 02:49:23 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Marco Molteni In-Reply-To: <20051019213807.2b676e95.molter@tin.it> Message-ID: <20051020024753.M98055@fledge.watson.org> References: <200510191715.21582.molter@tin.it> <20051019153655.GB4225@dan.emsphone.com> <20051019213807.2b676e95.molter@tin.it> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: hackers@freebsd.org Subject: Re: rc scripts: how to start a process that doesn't daemonize itself? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Oct 2005 01:49:25 -0000 On Wed, 19 Oct 2005, Marco Molteni wrote: >> Try putting the "&" in command_args; that way it'll only be used during >> startup. I do that in some of my homegrown rc.d scripts. A (probably >> cleaner) way is to set >> >> start_cmd="/usr/sbin/daemon /usr/local/bin/myprog" > > thanks to you and the others posters for the & trick. > > It works, but as you say it smells hackish. For one, it doesn't detach > from the controlling tty. Not a big deal when run from init I think, but > it may make a difference when run multiuser from a terminal (say myprog > forcestart). > > anyway, better than nothing ;-) The daemon(8) page claims it detaches from the tty. You may also want to use the -f argument to redirect stdio. If it isn't working properly, please file a PR, thanks! Robert N M Watson