]> git.tuebingen.mpg.de Git - paraslash.git/commit
daemon: Introduce parent_waits flag for daemonize().
authorAndre Noll <maan@systemlinux.org>
Sat, 12 Nov 2011 13:37:01 +0000 (14:37 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 13 Nov 2011 13:32:21 +0000 (14:32 +0100)
commit25ca796b7f7a4c5a57799cac2998a66ffde2a81a
treec371d387f861333271e425cb2d8574f1d8ac6135
parentb8ad8275c27afd58015dbc70ff9ce65637e96839
daemon: Introduce parent_waits flag for daemonize().

In daemon mode, para_server should not detach from the console
until it is listening on its command socket. The previous approach
turned out to be buggy and has been reverted in the previous commit.

This second attempt tries to get it right. It adds a boolean parameter
"parent_waits" to daemonize(). After daemonize() has forked, the
parent process does not exit immediately if parent_waits is true but
waits until the child process sends SIGTERM to its parent, or exits.

para_server makes use of the new flag in server_init(). The daemon
process (child) sends SIGTERM to its parent after the command socket
has been initialized. para_audiod, on the other hand, does not need
this feature, so it calls daemonize() with parent_waits == false to
get the old behaviour.
audiod.c
daemon.c
daemon.h
server.c