In the context of init scripts, according to the LSB specification, "Each conforming init script shall execute the commands in the file /lib/lsb/init-function", which then defines a couple of functions to be used when using daemons. One of those functions is start_daemon
, which obviously "runs the specified program as a daemon" while checking if the daemon is already running.
I'm in the process of daemonizing a service app of mine, and I'm looking at how other daemons are run to try to "fit in". In the process of looking how it's done elsewhere, I noticed that not a single daemon on my Ubuntu 10.04 machine uses start_daemon. They all call start-stop-daemon directly. Same goes for my Fedora 14 machine. Should I try to play nice and be the first one to use start_daemon, or is there really no point and start-stop-daemon is the way to go since everybody is already using that? Why is there no daemons using LSB's functions?
On my system, most scripts use
start-stop-daemon
, but two,exim4
andincron
usestart-daemon
.If you want to write scripts for portability and to comply with LSB, use
start_daemon
. On Ubuntu, it's implemented as a simple wrapper forstart-stop-daemon
.If you need the argument granularity provided by
start-stop-daemon
, use it.On Debian (well, Ubuntu), the
lsb-base
package has readme (at/usr/share/doc/lsb-base/README.Debian.gz
) which says:So, software packaged specifically for Debian usually uses
start-stop-daemon
. I can imagine that software ported from another system might usestart_daemon
, although if the other system has a similar policy, then the software wouldn't be usingstart_daemon
in the first place, so it might be no easier to port it usingstart_daemon
thanstart-stop-daemon
. I can also imagine that software which is packaged for many systems might usestart_daemon
, to enable a portable init script. Exim might be a good example of that.Personally, i think the readme's advice is terrible, bordering on criminal. We have a standard; if everyone adheres to it, software will be more portable, which is a good thing. Advising people not to use the standard passes on an opportunity to make the world a better place.