Daemon (computing)
In Unix and other computer multitasking operating systems, a daemon (/[invalid input: 'icon']ˈ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.
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.
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] Unix systems inherited this terminology. A derivation from the phrase "Disk And Execution MONitor" is a backronym.[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.
Pronunciation
The word daemon is an alternative spelling of demon,[3] and is /ˈ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]
Types of daemons
In a strictly technical sense, a Unix-like system process is a daemon when its parent process terminates and it 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
This article may contain unverified or indiscriminate information in embedded lists. (September 2010) |
Notable service daemons for Unix-like systems
- amd – Berkeley Automounter
- anacron – Executed delayed cron tasks at boot time
- apmd – Advanced Power Management Daemon
- arpwatch – watches for Ethernet IP address pairings that are resolved using the ARP protocol
- atd – Runs jobs queued using the at tool
- biod – Cooperates with a remote nfsd to handle client Network File System requests
- bootparmd – Internet Bootstrap Protocol server daemon
- configd – A daemon that maintains dynamic configuration information about the computer and its environment (mainly the network)
- crond – Task scheduler daemon
- cupsd – CUPS printer daemon
- devfsd – Device file system (devfs)
- dhcpd – Dynamic Host Configuration Protocol and Internet Bootstrap Protocol server
- fetchmail – daemon to retrieve mail from servers at regular intervals
- fingerd – Finger protocol server
- ftpd – File Transfer Protocol (FTP) server
- gated – routing daemon that handles multiple routing protocols and replaces routed and egpup
- gpm – General Purpose Mouse Daemon
- httpd – Hypertext Transfer Protocol (HTTP) daemon (web server)
- identd – Provides the identity of a user of a particular TCP connection
- inetd – Internet Superserver Daemon
- init – Initial process that spawns other processes
- imapd – Internet Message Access Protocol (IMAP) server daemon
- innd – InterNetNews server daemon
- ipchains – A deprecated packet forwarding and firewall daemon
- isdn – Integrated Services Digital Network (ISDN) interfacing server daemon
- kerneld – Automatically loads and unloads kernel modules
- klogd – Kernel log daemon (intercepts and logs Linux kernel messages)[4]
- kswapd – Kernel page swapping daemon
- kudzu – Detects and configures new or changed hardware during boot
- launchd – Init and operating system service management implementation on Mac OS X
- lpd – Line Printer Daemon protocol
- memcached – In-memory distributed memory caching daemon
- mpd – Music Player Daemon
- mountd – Part of typical Network File System implementation
- mysql – Database server daemon
- named – A Domain Name System (DNS) server daemon
- nfsd – Network File System (NFS) daemon
- nmbd – Network Message Block Daemon; part of Samba
- ntpd – Network Time Protocol (NTP) service daemon
- pcmcia – Provides generic PCMCIA services
- portmap
- postfix – A mail transfer agent used as a replacement for sendmail
- postgresql – Database server daemon
- retchmail – A mail retrieval agent
- rlprd – Remote line printer proxy daemon
- routed – Manages routing tables
- rpcbind – Remote Procedure Call Bind Daemon
- rquotad – Remote quota reporting, associated with Network File System
- rwalld – Allows users to write messages on remote terminals using rwall
- rwhod – Maintains the database used by the rwho and ruptime tools
- sched, swapper – Copies process regions to swap space to reclaim physical pages of memory
- sendmail – A mail transfer agent daemon
- smbd – Samba, an Server Message Block (SMB) daemon
- smtpd – Simple Mail Transfer Protocol Daemon
- snmpd – Simple Network Management Protocol Daemon
- sound – A sound server daemon
- squid – A web page caching proxy server daemon
- sshd – Secure Shell Server Daemon
- syncd – Keeps the file systems synchronized with system memory
- syslogd – Syslog daemon
- tcpd – Service wrapper restricts access to inetd based services through hosts.allow and hosts.deny
- telnetd – Telnet server daemon
- vhand – The "page stealing daemon" releases pages of memory for use by other processes
- vsftpd – "Very Secure FTP Daemon"
- webmin – Web based administration server daemon
- xfsd – X font server daemon
- xinetd – Enhanced Internet Superserver Daemon
- ypbind – A bind server for Network Information Service ("Yellow Pages")
Windows equivalent
In the Microsoft DOS environment, such programs were written as Terminate and Stay Resident (TSR) software. On Microsoft Windows NT systems, programs called services perform the functions of daemons. They run as processes, usually do not interact with the monitor, keyboard, and mouse, and may be launched by the operating system at boot time. With Windows 2000 and later versions, one can configure and manually start and stop Windows services using the Control Panel → Administrative Tools or typing "Services.msc" in the Run command on Start menu.
However, any Windows application can perform the role of a daemon, not just a service, and some daemons for Windows have the option of running as a normal process, where it still has no visual output.
Mac OS equivalent
On the original Mac OS, optional features and services were provided by files loaded at startup time that patched the operating system; these were known as system extensions and control panels. Later versions of classic Mac OS augmented these with fully fledged faceless background applications: regular applications that ran in the background. To the user, these were still described as regular system extensions.
Mac OS X, being a Unix system, has daemons. There is a category of software called services as well, but these are different in concept from Windows' services.
Etymology
According to Fernando J. Corbato who worked on Project MAC in 1963 his team is the first to use the term daemon. The use of the term daemon was inspired by Maxwell's daemon, in physics and thermodynamics as an imaginary agent which helped to sort molecules.[5]
We fancifully began to use the word daemon to describe background processes which worked tirelessly to perform system chores.
In the general sense, daemon is an older form of the word demon, from the Greek δαίμων. In the Unix System Administration Handbook, Evi Nemeth states the following about daemons:[6]
Many people equate the word "daemon" with the word "demon", implying some kind of satanic connection between UNIX and the underworld. This is an egregious misunderstanding. "Daemon" is actually a much older form of "demon"; daemons have no particular bias towards good or evil, but rather serve to help define a person's character or personality. The ancient Greeks' concept of a "personal daemon" was similar to the modern concept of a "guardian angel"—eudaemonia is the state of being helped or protected by a kindly spirit. As a rule, UNIX systems seem to be infested with both daemons and demons. (p.403)
A further characterization of the mythological symbolism is that a daemon is something which is not visible yet is always present and working its will. Plato's Socrates describes his own personal daemon to be something like the modern concept of a moral conscience:
The favour of the gods has given me a marvelous gift, which has never left me since my childhood. It is a voice which, when it makes itself heard, deters me from what I am about to do and never urges me on.
Popular Culture
In January of 2009, author Daniel Suarez published a book entitled Daemon, a technothriller about a computer genius who, on his death, unleashes a daemon program that lays the framework for a social revolution.
See also
- List of computer term etymologies
- Mailer Daemon (bounce message)
- Server
- Service Wrapper
- Terminate and Stay Resident
- User space
- Windows service
- Web service
References
- ^ a b c Eric S. Raymond. "daemon". The Jargon File. Retrieved 2008-10-22.
- ^ Fernando J. Corbató (2002-01-23). "Take Our Word for It". Retrieved 2006-08-20.
- ^ "Merriam-Webster definition of daemon". Merriam-Webster Online. Retrieved 2009-08-05.
- ^ http://unixhelp.ed.ac.uk/CGI/man-cgi?klogd+8
- ^ "The Origin of the word Daemon".
- ^ "The BSD Daemon". Freebsd.org. Retrieved 2008-11-15.
- ^ There is some doubt as to whether Theages was genuinely authored by Plato but this passage accurately articulates the Greek conception of a daemon.