daemonize(3)

_daemonize - make a process into a daemon

As shipped in IRIX 6.5.7. Unchanged since IRIX 6.5.

NAME
     _daemonize - make a process into a daemon

SYNOPSIS
     #include <unistd.h>

     int _daemonize(int flags, int fd1, int fd2, int fd3);

DESCRIPTION
     The _daemonize function does the common work needed ``to put a function
     into the background,'' or to make it into a ``daemon.''  That generally
     includes forking a new process, closing most files, and releasing the
     controlling tty.

     If flags & _DF_NOFORK is 0, then a new process in a new session is
     started.  Debugging is often easier with flags set to contain _DF_NOFORK.

     If flags & _DF_NOCHDIR is 0, then the current working directory is
     changed to /.  Otherwise, the current working directory is unchanged.

     If flags & _DF_NOCLOSE is 0, then all file descriptors except fd1, fd2,
     and fd3 are closed.  Because _daemonize closes all file descriptors,
     closelog() is called to stop logging cleanly.  The fd# arguments should
     be -1 if they are not file descriptors to be left open.

SEE ALSO
     close(2), chdir(2), fork(2), getdtablesize(2), syslog(3B), setsid(2),
     tty(1), tty(7)

DIAGNOSTICS
     The returned value -1 indicates that one of the necessary system calls
     failed.