xt_daemonize(3)

NAME
xt_daemonize() - Detach process from terminal

LIBRARY
#include <xtend/proc.h>
-lxtend

SYNOPSIS
int     xt_daemonize(int nochdir, int noclose)

ARGUMENTS
nochdir:    If true (non-zero), do not chdir("/")
noclose:    If true, do not redirect standard descriptors to /dev/null

DESCRIPTION
Daemonize a process, using the double-fork() method to ensure that it cannot attach to a controlling tty (terminal). The interface is identical to the BSD daemon(3) function, but daemon(3) only performs a single fork, so there is a risk that the resulting process could attach to a termimal. The double-fork() entails additional overhead compared to daemon(3), but ensures that the process cannot aquire a controlling terminal and be affected by signals from the keyboard. daemon(3) is deprecated on macOS as of this writing.

RETURN VALUES
0 on success, -1 on failure

EXAMPLES
xt_daemonize(0, 0);

SEE ALSO
daemon(3), fork(2), setsid(2)