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