Question about rc-scripts

Mel fbsd.questions at rachie.is-a-geek.net
Tue Oct 9 15:25:24 PDT 2007


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


More information about the freebsd-questions mailing list