Is LSB’s init script function “start_daemon” really used for real daemons or should I stick to start-stop-daemon

init.dlsb

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?

Best Answer

On my system, most scripts use start-stop-daemon, but two, exim4 and incron use start-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 for start-stop-daemon.

If you need the argument granularity provided by start-stop-daemon, use it.