Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Daemon (computing)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Computer program that runs as a background process}} {{For-multi|spirit in Classical Greek mythology|Daimon|broader coverage of the topic|Server (computing)}} {{more footnotes|date=June 2018}} [[File:Free and open-source-software display servers and UI toolkits.svg|thumb|right|400px|Components of some [[Linux]] [[desktop environment]]s that are daemons include [[D-Bus]], [[NetworkManager]] (here called ''unetwork''), [[PulseAudio]] (''usound''), and [[Avahi (software)|Avahi]].]] In [[computing]], a '''daemon''' is a [[computer program|program]] that runs as a [[background process]], rather than being under the direct control of an interactive user. Customary convention is to name a daemon process with the letter ''d'' as a suffix to indicate that it's a daemon. For example, {{mono|[[syslogd]]}} is a daemon that implements system logging facility, and {{mono|sshd}} is a daemon that serves incoming [[Secure Shell|SSH]] connections. Even though the concept can apply to many computing systems, the term ''daemon'' is used almost exclusively in the context of [[Unix]]-based systems. In other contexts, different terms are used for the same concept. Systems often start daemons at [[booting|boot]] 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== In the context of computing, the word is generally pronounced either as {{IPAc-en|ˈ|d|iː|m|ən}} {{respell|DEE|mən}} or {{IPAc-en|ˈ|d|eɪ|m|ən}} {{respell|DAY|mən}}.<ref name="jargon">{{Cite web|url=http://catb.org/~esr/jargon/html/D/daemon.html |title=daemon |author=Eric S. Raymond |author-link=Eric S. Raymond |access-date=2008-10-22 |work=[[Jargon File|The Jargon File]] }}</ref> The term was coined by the programmers at [[Project MAC|MIT's Project MAC]]. According to [[Fernando J. Corbató]], who worked on [[MIT Computer Science and Artificial Intelligence Laboratory#Project MAC|Project MAC]] around 1963, his team was the first to use the term daemon, inspired by [[Maxwell's demon]], an imaginary agent in physics and [[thermodynamics]] 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".<ref>{{Cite web|title=The Origin of the word Daemon|url=http://ei.cs.vt.edu/~history/Daemon.html}}</ref> [[Unix]] systems inherited this terminology. Maxwell's demon is consistent with Greek mythology's interpretation of a [[Daemon (mythology)|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 language|Greek]] δαίμων. In the ''Unix System Administration Handbook'' [[Evi Nemeth]] states the following about daemons:<ref>{{Cite web|title=The BSD Daemon|url=http://www.freebsd.org/copyright/daemon.html|access-date=2008-11-15|publisher=Freebsd.org}}</ref> {{bquote| Many people equate the word "daemon" with the word "demon", implying some kind of [[satanism|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 Greece|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.}} Alternative terms include ''[[Windows service|service]]'' (used in Windows, from Windows NT onwards, and later also in Linux), ''started task'' (IBM [[z/OS]]),<ref>{{cite web|url=https://www.ibm.com/docs/en/zos-basic-skills?topic=glossary-zos-terms-abbreviations|title=Glossary of z/OS terms and abbreviations|website=IBM Documentation|date=31 January 2006 |publisher=[[IBM]]}}</ref> and ''ghost job'' (XDS [[Universal Time-Sharing System|UTS]]). Sometimes the more general term ''server'' or ''server process'' is used, particularly for daemons that operate as part of [[Client–server model|client-server systems]].<ref>{{Cite web |title=sshd: OpenSSH server process {{!}} SSH Academy |url=https://www.ssh.com/academy/ssh/sshd |access-date=2023-12-04 |website=www.ssh.com |language=en}}</ref> A daemon that connects to a computer network is a [[network service]]. After the term was adopted for computer use, it was incorrectly<ref name="jargon" /> rationalized as a [[backronym]] for '''d'''isk '''a'''nd '''e'''xecution '''mon'''itor.<ref>{{cite web|url=http://www.linfo.org/daemon.html|title=Daemon Definition|website=www.linfo.org}}</ref><ref>{{cite web |url=https://bookstack.kb.ucla.edu/books/macos-windows-and-linux/page/what-is-a-daemon |title=What is a daemon? |work=UCLA Knowledge Base}}</ref><ref>{{cite web |url=https://www.kayshav.com/ddinfo/daemon.html |title=Daemon |website=Kayshav.com}}</ref> ==Implementations== ===Unix-like systems=== In a [[Unix-like]] system, the [[parent process]] of a daemon is often, but not always, the [[init]] process. A daemon is usually created either by the init process directly launching the daemon, by the daemon being run by an initialization script run by init, by the daemon being launched by a [[super-server]] launched by init. The init process in [[Research Unix]] and [[BSD]] starts daemons from an initialization script. A daemon started as a command in an initialization script must either [[Fork (operating system)|fork]] a child process and then immediately exit, or must be run as a background process using {{mono|&}}, so that the shell running the initialization script can continue after starting the daemon. In the former case, the daemon process run from the shell exits, thus causing init to adopt the child process that runs as the daemon; in the latter case, when the shell running the initialization script exits, the child daemon process is adopted by init.<ref>{{cite web |url=https://utcc.utoronto.ca/~cks/space/blog/unix/DaemonizationIsQuiteOld |title=(Unix) daemonization turns out to be quite old |date=October 3, 2024}}</ref> The versions of init in [[UNIX System III|System III]] and in [[UNIX System V|System V]] can run arbitrary commands and can be configured to run them once or to restart them when they terminate.<ref>{{cite book |url=https://bitsavers.org/pdf/att/unix/System_III/UNIX_Users_Manual_Release_3_Jun80.pdf#page=682 |title=UNIX User's Manual, Release 3.0 |date=June 1980 |at=INIT(8)}}</ref><ref>{{cite book |url=https://bitsavers.org/pdf/att/unix/System_III/UNIX_Users_Manual_Release_3_Jun80.pdf#page=619 |title=UNIX User's Manual, Release 3.0 |date=June 1980 |at=INITTAB(5)}}</ref><ref>{{cite book |url=https://bitsavers.org/pdf/att/unix/System_V_Release_1/301-926_UNIX_System_V_Release_1_Administators_Manual_Jun82.pdf#page=119 |title=UNIX System Administrator's Manua Release 5.0 |date=June 1982 |at=INIT(1M)}}</ref><ref>{{cite book |url=https://bitsavers.org/pdf/att/unix/System_V_Release_1/301-905_UNIX_System_V_Release_1_Users_Manual_Jan83.pdf#page=679 |title=UNIX User's Manual System V |date=January 1983 |at=INITTAB(4)}}</ref> The former mechanism can be used to run initialization scripts; daemons started from those scripts behave the same as in Research Unix and BSD. The latter mechanism can be used to run daemons directly from init. A daemon can also be launched from a user's command line. However, daemons launched in that fashion typically must perform other operations, such as dissociating the process from any controlling [[tty (Unix)|terminal]] (tty). Such procedures are often implemented in various convenience routines such as ''daemon(3)''. A daemon launched by an initialization script need not do these steps, but doing so allows the daemon to be restarted by a user if it exits;<ref>{{cite web |url=https://utcc.utoronto.ca/~cks/space/blog/unix/DaemonizationAndRestarts |title=Daemonization in Unix programs is probably about restarting programs |date=October 5, 2024}}</ref> init itself would not restart them.<ref>{{cite web |url=https://utcc.utoronto.ca/~cks/space/blog/unix/InitWasNotAServiceManager |title=Traditionally, init on Unix was not a service manager as such |date=October 4, 2024}}</ref> Operations such a daemon must do include: * Optionally removing unnecessary variables from environment. * Executing as a [[background (computer software)|background task]] by [[fork (system call)|forking]] and [[exit (system call)|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, <code>setsid()</code>: ** Dissociating from the controlling [[tty (Unix)|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]] ({{mono|/}}) as the current [[working directory]] so that the process does not keep any directory in use that may be on a [[Mount (computing)|mounted]] file system (allowing it to be unmounted). * Changing the [[umask]] to 0 to allow <code>open()</code>, <code>creat()</code>, and other operating system calls to provide their own permission masks and not to depend on the umask of the caller. * Redirecting [[file descriptor]]s 0, 1 and 2 for the [[standard streams]] ([[stdin]], [[stdout]] and [[stderr]]) to {{mono|/dev/null}} or a [[Computer data logging|logfile]], and closing all the other file descriptors inherited from the parent process. If the process is started by a [[super-server]] daemon, such as {{mono|[[inetd]]}}, {{mono|[[launchd]]}}, or {{mono|[[systemd]]}}, the super-server daemon will perform those functions for the process,<ref name=inetd>{{man|8|inetd|FreeBSD}}</ref><ref>{{man|5|launchd.plist|Darwin}}</ref><ref name=systemd_service>{{cite web|title=systemd.service|url=http://www.freedesktop.org/software/systemd/man/systemd.service.html|publisher=freedesktop.org|access-date=August 25, 2012}}</ref> except for old-style daemons not converted to run under {{mono|systemd}} and specified as {{mono|Type{{=}}forking}}<ref name=systemd_service/> and "multi-threaded" datagram servers under {{mono|inetd}}.<ref name=inetd/> ===MS-DOS=== In [[MS-DOS]], daemon-like functionality was implemented as a [[terminate-and-stay-resident program]] (TSR). ===Windows=== In [[Windows]], a [[Windows service]] provides the functionality of a daemon. It runs as a process, usually does not interact with the user (i.e. via monitor, keyboard, or mouse) and may be launched by the operating system at boot time. In [[Windows 2000]] and later versions, a Windows service is configured and controlled via various interfaces including the [[Control Panel (Windows)|Control Panel]], the [[Service Control Manager]] {{code|sc}} command, the {{code|net start}} and {{code|net stop}} commands, [[PowerShell]], or a custom program. 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. ===Mac=== In [[classic Mac OS]], optional features and services were provided by [[Extension (Mac OS)|system extensions]] and [[Control panel (Mac OS)|control panels]] {{endash}} files loaded at startup time that patched the operating system. Later versions of classic Mac OS augmented these with [[Extension (Mac OS)#Faceless background applications|faceless background applications]]: regular applications that ran in the background. To the user, these were still described as regular system extensions. The more modern [[macOS]], which is [[Unix]]-based, uses daemons but uses the term "services" to designate software that performs functions selected from the [[Services menu#macOS|Services menu]], rather than using that term for daemons, as Windows does. ==See also== {{Div col|colwidth=20em}} * [[List of computer term etymologies]] * [[List of Unix daemons]] * [[Service wrapper]] * [[Software bot]] * [[User space]] * [[Web service]] * [[Windows service]] {{div col end}} ==References== {{Reflist}} ==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 }} [[Category:Process (computing)]] [[Category:Servers (computing)]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Bquote
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Div col
(
edit
)
Template:Div col end
(
edit
)
Template:Endash
(
edit
)
Template:For-multi
(
edit
)
Template:IPAc-en
(
edit
)
Template:Man
(
edit
)
Template:Mono
(
edit
)
Template:More footnotes
(
edit
)
Template:Reflist
(
edit
)
Template:Respell
(
edit
)
Template:Short description
(
edit
)
Template:Webarchive
(
edit
)