1 #include <ccan/daemonize/daemonize.h>
8 /* This code is based on Stevens Advanced Programming in the UNIX
14 /* Separate from our parent via fork, so init inherits us. */
15 if ((pid = fork()) < 0)
20 /* Don't hold files open. */
25 /* Many routines write to stderr; that can cause chaos if used
26 * for something else, so set it here. */
27 if (open("/dev/null", O_WRONLY) != 0)
29 if (dup2(0, STDERR_FILENO) != STDERR_FILENO)
33 /* Session leader so ^C doesn't whack us. */
35 /* Move off any mount points we might be in. */
39 /* Discard our parent's old-fashioned umask prejudices. */