X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fdaemonize%2F_info;fp=ccan%2Fdaemonize%2F_info;h=2bdcaa97efa69556feb6bbfe60754d145ba6ef5e;hb=570c9c555f076e74f46141bb42b5d1d7ac89f632;hp=0000000000000000000000000000000000000000;hpb=8f61c0bccb152b2365baf70deac1e59264d7feb7;p=ccan diff --git a/ccan/daemonize/_info b/ccan/daemonize/_info new file mode 100644 index 00000000..2bdcaa97 --- /dev/null +++ b/ccan/daemonize/_info @@ -0,0 +1,54 @@ +#include +#include +#include "config.h" + +/** + * daemonize - routine to turn a process into a well-behaved daemon. + * + * Daemons should detach themselves thoroughly from the process which launched + * them, and not prevent any filesystems from being unmounted. daemonize() + * helps with the process. + * + * Example: + * #include + * #include + * #include + * #include + * #include + * + * static void usage(const char *name) + * { + * errx(1, "Usage: %s [--daemonize]\n", name); + * } + * + * // Wait for a minute, possibly as a daemon. + * int main(int argc, char *argv[]) + * { + * if (argc != 1) { + * if (argc == 2 && streq(argv[1], "--daemonize")) { + * if (!daemonize()) + * err(1, "Failed to become daemon"); + * } else + * usage(argv[1]); + * } + * sleep(60); + * exit(0); + * } + * + * Licence: BSD (2 clause, ie. MIT) + */ +int main(int argc, char *argv[]) +{ + if (argc != 2) + return 1; + + if (strcmp(argv[1], "depends") == 0) { + return 0; + } + + if (strcmp(argv[1], "libs") == 0) { + return 0; + } + + return 1; +}