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 ?


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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.