- Daemon (computer software)
In
Unix and other computer multitaskingoperating system s, a daemon (pronEng|ˈdiːmən or IPA|/ˈdeɪmən/ [cite web |url=http://foldoc.org/index.cgi?query=daemon |title=Jargon File entry for daemon |last=Raymond |first=Eric |accessdate=2007-07-18 |work=The Jargon File ] ) is acomputer 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) theinit 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 disassociating 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 devfsd on some
Linux systems), run scheduled tasks (likecron ), 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. [cite web|url=http://www.takeourword.com/TOW146/page4.html|author=Fernando J. Corbató |title=Take Our Word for It|date=2002-01-23|accessdate=2006-08-20]Unix systems inherited this terminology. Daemons are also characters in Greek mythology, some of whom handled tasks that the gods could not be bothered with, much as computer daemons often handle tasks in the background that the user cannot be bothered with. BSD and some of its derivatives have adopted a daemon as its mascot, although this mascot is actually acute stereotypical depiction of ademon fromChristianity .Pronunciation
The word "daemon", taken out of its computer science context, is correctly pronounced as IPA|/'dimən/ "(DEE-men)" [cite web |url=http://www.yourdictionary.com/ahd/d/d0004600.html |title=YourDictionary entry for daemon |accessdate=2007-07-18 |work=YourDictionary ] [cite web | url=http://dictionary.reference.com/browse/daemon |title=Dictionary.com entry for daemon |accessdate=2007-07-18 |work=Dictionary.com] [cite web |url=http://www.m-w.com/cgi-bin/audio.pl?demon001.wav=daemon |title=Merriam-Webster pronuncation of daemon |accessdate=2007-07-18 |work=Merriam-Webster Online] , i.e., as a
homonym of the word "demon". Perhaps due to the relative obscurity of the word in other contexts, it is not uncommon to hear it mispronounced as IPA|/'deɪmən/ "(DAY-men)".Types of daemons
In a strictly technical sense, in the Unix world, a process comprises a daemon when it has process number 1 (
init ) as its parent process and no controlling terminal. The init process adopts any process whose parent process terminates. The common method for a process to become a daemon involves:
* Disassociating from the controlling tty
* Becoming a session leader
* Becoming aprocess 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. Thisidiom is sometimes summarized with the phrase "fork off and die"
* Setting theroot directory ("/") as the currentworking 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 theumask 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 stderrIn common Unix usage a daemon may be any background process, whether a child of init or not. Unix users sometimes spell daemon as "demon", and most usually pronounce the word that way.
Windows equivalent
In the Microsoft DOS environment, such programs were written as
Terminate and Stay Resident (TSR) software. OnMicrosoft Windows 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. Starting with Windows NT and in later systems, one can configure and manually start and stop Windows services using the Control Panel -> Services applet.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 aUnix -like system, has daemons. There is a category of software called "services" as well, but these are different in concept to Windows' services.Etymology
In the general sense, daemon is an older form of the word demon. In the Unix System Administration Handbook, Evi Nemeth states the following about daemons: [ [http://www.freebsd.org/copyright/daemon.html The BSD Daemon ] ]
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)References
ee also
* Server
*List of computer term etymologies
*Windows service
*Terminate and Stay Resident
*User space
*NTVDM
*Apcupsd
*Windows Workflow Foundation
* Runtime DLL, COM Library
*Microsoft ServicesExternal links
* [http://www.annodex.net/cgi-bin/man/man2html?start-stop-daemon+8 start-stop-daemon man page] (Debian package)
* [http://www.webreference.com/perl/tutorial/9/ Tutorial: Unix Daemons in Perl]
* [http://www-theorie.physik.unizh.ch/~dpotter/howto/daemonize How to daemonize in Linux]
* [http://www.enderunix.org/docs/eng/daemon.php Unix Daemon Server Programming]
* [http://web.archive.org/web/20051216101425/http://lug.umbc.edu/~mabzug1/bash-httpd.html http daemon in Bash]
* [http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/cl/rpcbind.htm IBM RPCBIND] , See interrupter, encoder/decoder/descriptor (ofassembly code ), JVM (background services)
Wikimedia Foundation. 2010.