Creation
In a strictly technical sense, a Unix-like system process is a daemon when its parent process terminates and the daemon is assigned the init process (process number 1) as its parent process and has no controlling terminal. However, more commonly, a daemon may be any background process, whether a child of the init process or not.
On a Unix-like system, the common method for a process to become a daemon, when the process is started from the command line or from a startup script such as an init script or a SystemStarter script, involves:
- Dissociating from the controlling tty
- Becoming a session leader
- Becoming a process group leader
- Executing as a background task by forking and exiting (once or twice). This is required sometimes for the process to become a session leader. It also allows the parent process to continue its normal execution.
- Setting the root directory (/) as the current working directory so that the process does not keep any directory in use that may be on a mounted file system (allowing it to be unmounted).
- Changing the umask to 0 to allow open, creat, et al. operating system calls to provide their own permission masks and not to depend on the umask of the caller
- Closing all inherited files at the time of execution that are left open by the parent process, including file descriptors 0, 1 and 2 (stdin, stdout, stderr). Required files will be opened later.
- Using a logfile, the console, or /dev/null as stdin, stdout, and stderr
If the process is started by a super-server daemon, such as inetd, launchd, or systemd, the super-server daemon will perform those functions for the process (except for old-style daemons not converted to run under systemd and specified as Type=forking and "multi-threaded" datagram servers under inetd).
Read more about this topic: Daemon (computing)
Famous quotes containing the word creation:
“Hes indestructible. Frankensteins creation is mans challenge to the laws of life and death.”
—Edward T. Lowe, and Erle C. Kenton. Dr. Edelman (Onslow Stevens)
“The creation of strong-minded women, so-called, is due to the individualism of men, to the modern selfish and speculative spirit which absorbs everything within itself and leaves women nothing but self-assertion for their protection and support.”
—Jennie June Croly 18291901, U.S. founder of the womans club movement, journalist, author, editor. Demorests Illustrated Monthly and Mirror of Fashions, p. 44 (February 1870)
“Since we are assured that the all-wise Creator has observed the most exact proportions of number, weight and measure in the make of all things, the most likely way therefore to get any insight into the nature of those parts of the Creation which come within our observation must in all reason be to number, weigh and measure.”
—Stephen Hales (16771761)