From owner-freebsd-questions@FreeBSD.ORG Tue Oct 9 22:25:24 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C1B316A417 for ; Tue, 9 Oct 2007 22:25:24 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from snoogles.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id F328013C455 for ; Tue, 9 Oct 2007 22:25:23 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from localhost (localhost [127.0.0.1]) by snoogles.rachie.is-a-geek.net (Postfix) with ESMTP id 239761CDEE for ; Tue, 9 Oct 2007 14:25:23 -0800 (AKDT) From: Mel To: freebsd-questions@freebsd.org Date: Wed, 10 Oct 2007 00:25:21 +0200 User-Agent: KMail/1.9.7 References: <470AB2FC.8070006@rowyerboat.com> <6.0.0.22.2.20071008183414.025a1e88@mail.computinginnovations.com> <470AD44A.4070601@rowyerboat.com> In-Reply-To: <470AD44A.4070601@rowyerboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200710100025.21550.fbsd.questions@rachie.is-a-geek.net> Subject: Re: Question about rc-scripts X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Oct 2007 22:25:24 -0000 On Tuesday 09 October 2007 03:07:22 Stephen Allen wrote: > Hi Derek, > > > Not all scripts create a pid file is the simple answer. > > I didn't see how the isc-dhcpd script or dovecot created a pid, so I > assumed it was something that rc.subr took care of. > > > Your script should create the pid file on start, remove it on stop, and > > simply cat that file on a status. If you want help with your script, > > post it, and I'm sure one of us will give you a hand. > > Again, I thought the rc.subr functions took care of all that for you > (unless you wanted something special from those commands). Creation of pid files isn't supported in /etc/rc.subr. It's a burdon of the application to do this for you, however, if your application doesn't do this, you can possibly use daemon(8) for the start_cmd, to create one for you. This is however - quite up to the application. Some applications daemonize themselves by forking a child and detach the parent, in which case the pid file created by the daemon(8) command is useless, because it records the detached parent, not the running child. On the other hand, pid files are a convenience, not a requirement for rc scripts. If no pidfile variable is defined, it will simply `killall $name`. > I've posted the script (changed quite a lot from vendor supplied) at: > http://www.pastebin.ca/730238 I'd make the start_cmd as follows: start_cmd="${name}_start" dbgw_start() { echo "Starting ${name}" /usr/bin/nice -5 /usr/sbin/daemon -p ${pidfile} ${command} \ ${dbgw_flags} ${command_args} } -- Mel