DAEMON(1)

NAME
daemon - detach a process from its controlling environment

SYNOPSIS
daemon [-cdDeWu] [-p priority] <cmd> [args]

DESCRIPTION
The daemon command will detach a process from its controlling environment including terminal, process group, parent, any files opened to ttys, and renices to 15; plus optionally other things. It will return the process id of the daemonized program.

-c  Close all file descriptors > 2 instead of only those attached to ttys

-C  Close all file descriptors (including 0, 1, 2). This is not recommended because so many programs try to do a half-hearted daemonization by dup2("/dev/null",{0,1,2}). This is fine except that if 0, 1, and 2 were *closed* and it had tried to open files (like syslog) before this, then those other files would be closed by the dup.

-d  Chdir("/") to move off possible mounted filesystems

-e  Set the environment of the new process to PATH=/usr/bin:/usr/ucb:/usr/etc:. Everything else is dropped. Note: This may effect whether the program is found or not

-E  Set the environment of the new process to something more reasonable. Everything else is dropped. Note: This may effect whether the program is found or not

-u  umask(0);

-D  Effect of -cdeu

-pnumber
    Set the new process priority to zero instead of 15 (the default).

SEE ALSO
bg(sh) seth@ctr.columbia.edu