1

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?

Fred
  • 303
  • 1
  • 4
  • 7

2 Answers2

2

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.

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
1

On Debian (well, Ubuntu), the lsb-base package has readme (at /usr/share/doc/lsb-base/README.Debian.gz) which says:

Note: Debian packages probably should use start-stop-daemon directly; however, these functions may be useful in porting init scripts from other distributions.

So, software packaged specifically for Debian usually uses start-stop-daemon. I can imagine that software ported from another system might use start_daemon, although if the other system has a similar policy, then the software wouldn't be using start_daemon in the first place, so it might be no easier to port it using start_daemon than start-stop-daemon. I can also imagine that software which is packaged for many systems might use start_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.

Tom Anderson
  • 387
  • 1
  • 11
  • Only hardly anyone abides by the LSB standard, or even claims to, because it was a stupid idea to start with. Sometimes using their tools is convenient, but it is not seen as *standard* by many. – Jürgen Strobel Jan 16 '14 at 09:51
  • 1
    @JürgenStrobel: It's clear that LSB is not seen as standard; that's more or less what my answer says! I am afraid i do not agree that it was a stupid idea, though. Standards are good, because they reduce the effort required of software developers like me to make their code portable. The LSB is not a perfect standard, but that makes it a poor implementation of a good idea, not a stupid idea. – Tom Anderson Jan 18 '14 at 13:42
  • Not every standard is good, especially when published by a small group of companies with their own special interests which may be at odds with the rest of the Linux community. I advise people to ignore LSB freely and focus on building a good product. To make your product portable just use the most community accepted tools (ain't LSB) and leave the dist packaging to distribution maintainers. – Jürgen Strobel Jan 18 '14 at 21:08