6 * daemon_with_notify - daemonize a process, can wait for child to signal readiness
8 * Daemons should detach themselves thoroughly from the process which launched
9 * them, and not prevent any filesystems from being unmounted. daemonize()
10 * helps with the process.
12 * Daemon-with-notify is different in that the child can send a SIGUSR1 to
13 * the parent to indicate it has started (e.g. after memory allocation and
14 * other things that may fail) so that the parent can return a success or
15 * failing exit code and init scripts can pick this up easily.
18 * #include <ccan/daemon_with_notify/daemon_with_notify.h>
19 * #include <ccan/str/str.h>
24 * static void usage(const char *name)
26 * errx(1, "Usage: %s [--daemonize]\n", name);
29 * // Wait for a minute, possibly as a daemon.
30 * int main(int argc, char *argv[])
33 * if (argc == 2 && streq(argv[1], "--daemonize")) {
34 * if (!daemonize(1, 1, 1))
35 * err(1, "Failed to become daemon");
39 * sleep(10); // do some init here
41 * sleep(20); // will be done in child, detached from parent
45 * License: BSD (3 clause)
46 * Author: Stewart Smith <stewart@flamingspork.com>
48 int main(int argc, char *argv[])
53 if (strcmp(argv[1], "depends") == 0) {
57 if (strcmp(argv[1], "libs") == 0) {