summaryrefslogtreecommitdiff
path: root/ccan/daemonize/daemonize.h
blob: 1f473eae22bfc5fca150066606c326801c57c990 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* Licensed under BSD-MIT - see LICENSE file for details */
#ifndef CCAN_DAEMONIZE_H
#define CCAN_DAEMONIZE_H
#include <stdbool.h>

/**
 * daemonize - turn this process into a daemon.
 *
 * This routine forks us off to become a daemon.  It returns false on failure
 * (eg. fork(), chdir or open failed) and sets errno.
 *
 * Side effects for programmers to be aware of:
 *  - PID changes (our parent exits, we become child of init)
 *  - stdin and stdout file descriptors are closed
 *  - stderr is reopened to /dev/null so you don't reuse it
 *  - Current working directory changes to /
 *  - Umask is set to 0.
 */
bool daemonize(void);

#endif /* CCAN_DAEMONIZE_H */