Daemon (computing)
   HOME

TheInfoList



OR:

In multitasking computer
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s, a daemon ( or ) is a
computer program A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. Computer programs are one component of software, which also includes software documentation, documentation and oth ...
that runs as a
background process A background process is a computer process that runs ''behind the scenes'' (i.e., in the background) and without user intervention. Typical tasks for these processes include logging, system monitoring, scheduling, and user notification. The backgr ...
, rather than being under the direct control of an interactive user. Traditionally, the process names of a daemon end with the letter ''d'', for clarification that the process is in fact a daemon, and for differentiation between a daemon and a normal computer program. For example, is a daemon that implements system logging facility, and is a daemon that serves incoming SSH connections. In a
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
environment, the parent process of a daemon is often, but not always, the
init In Unix-based computer operating systems, init (short for ''initialization'') is the first process started during booting of the computer system. Init is a daemon process that continues running until the system is shut down. It is the direc ...
process. A daemon is usually created either by a process forking a child process and then immediately exiting, thus causing init to adopt the child process, or by the init process directly launching the daemon. In addition, a daemon launched by forking and exiting typically must perform other operations, such as dissociating the process from any controlling
terminal Terminal may refer to: Computing Hardware * Terminal (electronics), a device for joining electrical circuits together * Terminal (telecommunication), a device communicating over a line * Computer terminal, a set of primary input and output devi ...
(tty). Such procedures are often implemented in various convenience routines such as ''daemon(3)'' in Unix. Systems often start daemons at
boot A boot is a type of footwear. Most boots mainly cover the foot and the ankle, while some also cover some part of the lower calf. Some boots extend up the leg, sometimes as far as the knee or even the hip. Most boots have a heel that is c ...
time that will respond to network requests, hardware activity, or other programs by performing some task. Daemons such as cron may also perform defined tasks at scheduled times.


Terminology

The term was coined by the programmers at MIT's Project MAC. According to Fernando J. Corbató, who worked on Project MAC in 1963, his team was the first to use the term daemon, inspired by Maxwell's demon, an imaginary agent in physics and
thermodynamics Thermodynamics is a branch of physics that deals with heat, work, and temperature, and their relation to energy, entropy, and the physical properties of matter and radiation. The behavior of these quantities is governed by the four laws ...
that helped to sort molecules, stating, "We fancifully began to use the word daemon to describe background processes that worked tirelessly to perform system chores".
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
systems inherited this terminology. Maxwell's demon is consistent with Greek mythology's interpretation of a daemon as a supernatural being working in the background. In the general sense, daemon is an older form of the word "demon", from the Greek δαίμων. In the ''Unix System Administration Handbook''
Evi Nemeth Evi Nemeth (born June 7, 1940 – missing-at-sea June or July, 2013) was an engineer, author, and teacher known for her expertise in computer system administration and networks. She was the lead author of the "bibles" of system administration: '' ...
states the following about daemons: A further characterization of the mythological symbolism is that a daemon is something that is not visible yet is always present and working its will. In the ''
Theages ''Theages'' ( el, Θεάγης) is a dialogue attributed to Plato, featuring Demodocus, Socrates and Theages. There is debate over its authenticity; W. R. M. Lamb draws this conclusion from his opinion that the work is inferior and un-Socratic ...
'', attributed to
Plato Plato ( ; grc-gre, Πλάτων ; 428/427 or 424/423 – 348/347 BC) was a Greek philosopher born in Athens during the Classical period in Ancient Greece. He founded the Platonist school of thought and the Academy, the first institution ...
,
Socrates Socrates (; ; –399 BC) was a Greek philosopher from Athens who is credited as the founder of Western philosophy and among the first moral philosophers of the ethical tradition of thought. An enigmatic figure, Socrates authored no t ...
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 that, when it makes itself heard, deters me from what I am about to do and never urges me on". In modern usage, the word ''daemon'' is pronounced . In the context of computer software, the original pronunciation has drifted to for some speakers. Alternative terms for ''daemon'' are '' service'' (used in Windows, from Windows NT onwards, and later also in Linux), ''started task'' (IBM z/OS), and ''ghost job'' (XDS UTS). After the term was adopted for computer use, it was rationalized as a
backronym A backronym is an acronym formed from an already existing word by expanding its letters into the words of a phrase. Backronyms may be invented with either serious or humorous intent, or they may be a type of false etymology or folk etymology. The ...
for Disk And Execution MONitor. Daemons that connect to a computer network are examples of network services.


Implementations


Unix-like systems

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 In Unix-based computer operating systems, init (short for ''initialization'') is the first process started during booting of the computer system. Init is a daemon process that continues running until the system is shut down. It is the direc ...
process (process number 1) as its parent process and has no controlling terminal. However, more generally, 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 In Unix-based computer operating systems, init (short for ''initialization'') is the first process started during booting of the computer system. Init is a daemon process that continues running until the system is shut down. It is the direc ...
script or a SystemStarter script, involves: * Optionally removing unnecessary variables from environment. * Executing as a background task by forking and exiting (in the parent "half" of the fork). This allows daemon's parent (shell or startup process) to receive exit notification and continue its normal execution. * Detaching from the invoking session, usually accomplished by a single operation, setsid(): ** Dissociating from the controlling tty. ** Creating a new session and becoming the session leader of that session. ** Becoming a process group leader. * If the daemon wants to ensure that it will not acquire a new controlling tty even by accident (which happens when a session leader without a controlling tty opens a free tty), it may fork and exit again. This means that it is no longer a session leader in the new session, and cannot acquire a controlling tty. * Setting the
root directory In a computer file system, and primarily used in the Unix and Unix-like operating systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the trunk of a tree, as the starting point where all branche ...
() 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(), and other operating system calls to provide their own permission masks and not to depend on the umask of the caller. * Redirecting file descriptors 0, 1 and 2 for the standard streams ( stdin, stdout and
stderr In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (std ...
) to or a
logfile In computing, logging is the act of keeping a log of events that occur in a computer system, such as problems, errors or just information on current operations. These events may occur in the operating system or in other software. A message o ...
, and closing all the other file descriptors inherited from the parent process. If the process is started by a
super-server A super-server or sometimes called a service dispatcher is a type of daemon run generally on Unix-like systems. Usage A super-server starts other servers when needed, normally with access to them checked by a TCP wrapper. It uses very few res ...
daemon, such as , , or , the super-server daemon will perform those functions for the process, except for old-style daemons not converted to run under and specified as and "multi-threaded" datagram servers under .


MS-DOS

In the Microsoft DOS environment, daemon-like programs were implemented as terminate-and-stay-resident programs (TSR).


Windows NT

On
Microsoft Windows NT Windows NT is a proprietary graphical operating system produced by Microsoft, the first version of which was released on July 27, 1993. It is a processor-independent, multiprocessing and multi-user operating system. The first version of Win ...
systems, programs called
Windows service In Windows NT operating systems, a Windows service is a computer program that operates in the background. It is similar in concept to a Unix daemon. A Windows service must conform to the interface rules and protocols of the Service Control Manag ...
s 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. In
Windows 2000 Windows 2000 is a major release of the Windows NT operating system developed by Microsoft and oriented towards businesses. It was the direct successor to Windows NT 4.0, and was released to manufacturing on December 15, 1999, and was offici ...
and later versions, Windows services are configured and manually started and stopped using the Control Panel, a dedicated control/configuration program, the Service Controller component of the
Service Control Manager Service Control Manager (SCM) is a special system process under the Windows NT family of operating systems, which starts, stops and interacts with Windows service processes. It is located in the %SystemRoot%\System32\services.exe executable. Serv ...
( command), the and commands or the PowerShell scripting system. However, any Windows application can perform the role of a daemon, not just a service, and some Windows daemons have the option of running as a normal process.


Classic Mac OS and macOS

On the classic 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.
macOS macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and la ...
, which is a
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
system, uses daemons but uses the term "services" to designate software that performs functions selected from the Services menu, rather than using that term for daemons, as Windows does.


See also

*
List of computer term etymologies This is a list of the origins of computer-related terms or terms used in the computing world (i.e., a list of computer term etymologies). It relates to both computer hardware and computer software. Names of many computer terms, especially compu ...
* List of Unix daemons *
Service wrapper A service wrapper is a computer program that wraps arbitrary programs thus enabling them to be installed and run as Windows Services or Unix daemons, programs that run in the background, rather than under the direct control of a user. They are of ...
*
Software bot A software bot is a type of software agent in the service of software project management and software engineering. A software bot has an identity and potentially personified aspects in order to serve their stakeholders. Software bots often compose ...
* Terminate and stay resident program * User space * Web service *
Windows service In Windows NT operating systems, a Windows service is a computer program that operates in the background. It is similar in concept to a Unix daemon. A Windows service must conform to the interface rules and protocols of the Service Control Manag ...


References


External links

* {{Webarchive, url=https://web.archive.org/web/20191030233137/http://www.enderunix.org/docs/eng/daemon.php , title=Unix Daemon Server Programming , date=2019-10-30
Linux Daemon Writing HOWTO
Process (computing) Servers (computing)