3

I am writing my first init conf file using upstart. I would like to know what are the advantages of starting my daemon using start-stop-daemon.

Why is it better then just:

exec /path/to/my/daemon {args}

is there any obligation to use start-stop-daemon to start daemons ?

1 Answer 1

1

The only reason I have come up with to use start-stop-daemon is if the pre-start or post-stop sections need to be run as root, but the main process needs another user. Example here:

# Create directory with the daemon's user (need to run this as root)
pre-start exec install -o _foo -g _foo -d /run/foo

# Use start-stop-daemon to run the daemon as another user and group
exec start-stop-daemon -S -q -c _foo:_foo -x /usr/sbin/foo -- {args}

The setuid and setgid stanzas will not work in this situation because the pre-start process will have the unpriveleged user and will not be able to create /run/foo.

Other than that, just use exec.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .