aboutsummaryrefslogtreecommitdiff
path: root/lib/daemon.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2009-12-17 10:56:01 -0800
committerBen Pfaff <blp@nicira.com>2009-12-18 13:37:44 -0800
commit95440284bdf8ac9a94c3e119d011d76acab577a7 (patch)
tree503a473672b4bfd0a6dee762480bcca9f10e1d75 /lib/daemon.h
parent058fd2a2741deff874db53f0d7cdbf743e1f2a0f (diff)
daemon: Allow daemon child process to report success or failure to parent.
There are conflicting pressures in startup of a daemon process: * The parent process should exit with an error code if the daemon cannot start up successfully. * Some startup actions must be performed in the child process, not in the parent. The most obvious of these are file locking, since child processes do not inherit locks, and anything that requires knowing the child process's PID (e.g. unixctl sockets). Until now, this conflict has usually been handled by giving up part of the first property, i.e. in some cases the parent process would exit successfully and the child immediately afterward exit with a failure code. This commit introduces a better approach, by allowing daemons to perform startup work in the child and only then signal the parent that they have successfully started. If the child instead exits without signaling success, the parent passes this exit code along to its own parent. This commit also modifies the daemons that can usefully take advantage of this new feature to do so.
Diffstat (limited to 'lib/daemon.h')
-rw-r--r--lib/daemon.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/daemon.h b/lib/daemon.h
index 06280ac2..8ded63f1 100644
--- a/lib/daemon.h
+++ b/lib/daemon.h
@@ -59,6 +59,8 @@ bool is_chdir_enabled(void);
void set_detach(void);
bool get_detach(void);
void daemonize(void);
+void daemonize_start(void);
+void daemonize_complete(void);
void die_if_already_running(void);
void ignore_existing_pidfile(void);
void daemon_usage(void);