]> git.ozlabs.org Git - ccan/blob - ccan/daemon-with-notify/daemon.h
f80e7f518c63030012e79c013d66338b10747f17
[ccan] / ccan / daemon-with-notify / daemon.h
1 #ifndef CCAN_DAEMON_WITH_NOTIFY_H
2 #define CCAN_DAEMON_WITH_NOTIFY_H
3
4 /**
5  * daemonize - turns this process into a daemon
6  *
7  * This routine will fork() us off to become a daemon. It will return
8  * -1 on error and 0 on success.
9  *
10  * It has a few optional behaviours:
11  * @nochdir: if nochdir is set, it won't chdir to /
12  *   this means we could hold onto mounts
13  * @noclose: if noclose is set, we won't close stdout, stdin and stderr.
14  * @wait_sigusr1: if wait_sigusr1 is set, the parent will not exit until the
15  *   child has either exited OR it receives a SIGUSR1 signal. You can use this
16  *   to have the parent only exit when your process has done all the
17  *   danegerous initialization that could cause it to fail to start
18  *   (e.g. allocating large amounts of memory, replaying REDO logs).
19  *   This allows init scripts starting the daemon to easily report
20  *   success/failure.
21  */
22 int daemonize(int nochdir, int noclose, int wait_sigusr1);
23
24 /**
25  * daemon_is_ready - signals parent that it can exit, we started okay
26  *
27  * After a daemonize() call, this function will send a SIGUSR1 to the parent
28  * telling it to exit as we have started up okay.
29  */
30 int daemon_is_ready(void);
31
32 #endif /* CCAN_DAEMON_WITH_NOTIFY_H */