From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 19 19:36:40 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 D5D9516A41F for ; Wed, 19 Oct 2005 19:36:40 +0000 (GMT) (envelope-from molter@tin.it) Received: from vsmtp1.tin.it (vsmtp1.tin.it [212.216.176.141]) by mx1.FreeBSD.org (Postfix) with ESMTP id 59E9443D5A for ; Wed, 19 Oct 2005 19:36:39 +0000 (GMT) (envelope-from molter@tin.it) Received: from tortellino.codalunga (82.122.119.121) by vsmtp1.tin.it (7.2.060.1) (authenticated as molter@tin.it) id 43567E2D0001B191 for hackers@freebsd.org; Wed, 19 Oct 2005 21:36:35 +0200 Received: by tortellino.codalunga (Postfix, from userid 1001) id 3B83B8126; Wed, 19 Oct 2005 21:38:07 +0200 (CEST) Date: Wed, 19 Oct 2005 21:38:07 +0200 From: Marco Molteni To: hackers@freebsd.org Message-Id: <20051019213807.2b676e95.molter@tin.it> In-Reply-To: <20051019153655.GB4225@dan.emsphone.com> References: <200510191715.21582.molter@tin.it> <20051019153655.GB4225@dan.emsphone.com> X-Mailer: Sylpheed version 1.0.5 (GTK+ 1.2.10; i386-portbld-freebsd6.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: 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: Wed, 19 Oct 2005 19:36:41 -0000 On Wed, 19 Oct 2005 10:36:55 -0500 Dan Nelson wrote: > In the last episode (Oct 19), Marco Molteni said: > > I have a program that I would like to control via a rc script, > > say /usr/local/etc/rc.d/myprog > > > > problem is this program needs to be put explicitly in background. > > > > I was playing with things like > > > > command="/usr/sbin/daemon /usr/local/bin/myprog" > > > > but this obviously works only for the start case. > > > > Should I just override start() completely or is there a > > common way to do it? I don't think I can simply pass a "&" > > somewhere... > > 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 ;-) thanks again marco -- He who receives an idea from me, receives instruction himself without lessening mine; as he who lights his taper at mine, receives light without darkening me. -- Thomas Jefferson