Am 08.09.2011 12:08, schrieb Clemens Fruhwirth:
If you use Debian, you might have come across start-stop-daemon. It's part of the dpkg package and encapsulates all the knowledge, they learnt when dealing with starting and stopping daemons. It has plenty of features ranging from:
* handling pidfiles more intimately (checking the pid files content, verifying that the pid given actually is the executable in question) * changing UID/GID * chrooting, nice-ing * retry starting if daemon dies * creating pid files when the process doesn't do it, etc, etc.
curl http://clemens.endorphin.org/start-stop-daemon.c | less if you want to have look for yourself. It's a single C file.
To me handling pid files correctly is the biggest win. The paradigm used commonly in arch
PID=`pidof -o %PPID /usr/bin/executable` [ -z "$PID" ] && /usr/bin/executable
is flawed and does not work reliably as shown here https://bugs.archlinux.org/task/17138
I propose to switch to start-stop-daemon and deprecate the method above.
http://clemens.endorphin.org/sshd-start-stop-daemon.diff is an example of an rc.d script ported to start-stop-daemon. The paradigm -- to my personal taste -- is clean and simple. The diffstat is negative LOC-wise.
We could either take the aur/start-stop-daemon packaging which references dpkg.tar.gz or include into another core package. start-stop-daemon.c is public domain. -- Fruhwirth Clemens http://clemens.endorphin.org
Forwarding to the dev list, in case someone doesn't notice it here. In principle, I think this is a good idea. I want to hear Tom's opinion though, as this is closely initscripts-related.