Category Archives: Daemon (computer software)

Daemon (computer software)


Daemon (computer software)

From Wikipedia, the free encyclopedia

In Unix and other computer multitasking operating systems, a daemon/ˈdeɪmən/ or /ˈdiːmən/)[1] is a computer program that runs in the background, rather than under the direct control of a user; they are usually initiated as background processes. Typically daemons have names that end with the letter “d”: for example, syslogd, the daemon that handles the system log, or sshd, which handles incoming SSH connections. (pronounced
In a Unix environment, the parent process of a daemon is often (but not always) the init process (PID=1). Processes usually become daemons by forking a child process and then having their parent process immediately exit, thus causing init to adopt the child process. This is a somewhat simplified view of the process as other operations are generally performed, such as dissociating the daemon process from any controlling tty. Convenience routines such as daemon(3) exist in some UNIX systems for that purpose.
Systems often start (or “launch”) daemons at boot time: they often serve the function of responding to network requests, hardware activity, or other programs by performing some task. Daemons can also configure hardware (like udevd on some GNU/Linux systems), run scheduled tasks (like cron), and perform a variety of other tasks.

Contents

[show]

[edit] Terminology

The term was coined by the programmers of MIT’s Project MAC. They took the name from Maxwell’s demon, an imaginary being from a famous thought experiment that constantly works in the background, sorting molecules.[2] Unixbackronym.[1] Daemons are also characters in Greek mythology, some of whom handled tasks that the gods could not be bothered with. BSD and some of its derivatives have adopted a daemon as its mascot, although this mascot is actually a cute variation of the demons which appear in Christian artwork. systems inherited this terminology. A derivation from the phrase “Disk and Execution Monitor” is a

The BSD daemon, also called Beastie, as drawn by John Lasseter. His widely known and popular take on the BSD mascot first showed up on a book cover in 1988.

The BSD daemon, nicknamed Beastie, is the generic mascot of BSD operating systems.

[edit] Pronunciation

The word daemon is an alternative spelling of demon,[3] and in other contexts is pronounced /ˈdiːmən/ DEE-mən. In the context of computer software, the original pronunciation /ˈdiːmən/ has drifted to /ˈdeɪmən/ DAY-mən for some speakers.[1]

[edit] Types of daemons

In a strictly technical sense, a Unix-like system process is a daemon when its parent process terminates and is therefore ‘adopted’ by 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 init or not.
The common method for a process to become a daemon involves:
  • Dissociating from the controlling tty
  • Becoming a session leader
  • Becoming a process group leader
  • Staying in the background 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. This idiom is sometimes summarized with the phrase “fork off and die”
  • Setting the root directory (“/”) as the current working directory so that the process will 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. calls to provide their own permission masks and not to depend on the umask of the caller
  • Closing all inherited open 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