<s>
In	O
multitasking	B-Operating_System
computer	B-General_Concept
operating	I-General_Concept
systems	I-General_Concept
,	O
a	O
daemon	B-Operating_System
(	O
or	O
)	O
is	O
a	O
computer	B-Application
program	I-Application
that	O
runs	O
as	O
a	O
background	B-Operating_System
process	I-Operating_System
,	O
rather	O
than	O
being	O
under	O
the	O
direct	O
control	O
of	O
an	O
interactive	O
user	O
.	O
</s>
<s>
Traditionally	O
,	O
the	O
process	O
names	O
of	O
a	O
daemon	B-Operating_System
end	O
with	O
the	O
letter	O
d	O
,	O
for	O
clarification	O
that	O
the	O
process	O
is	O
in	O
fact	O
a	O
daemon	B-Operating_System
,	O
and	O
for	O
differentiation	O
between	O
a	O
daemon	B-Operating_System
and	O
a	O
normal	O
computer	B-Application
program	I-Application
.	O
</s>
<s>
For	O
example	O
,	O
is	O
a	O
daemon	B-Operating_System
that	O
implements	O
system	O
logging	B-Application
facility	O
,	O
and	O
is	O
a	O
daemon	B-Operating_System
that	O
serves	O
incoming	O
SSH	B-Protocol
connections	O
.	O
</s>
<s>
In	O
a	O
Unix	B-Application
environment	O
,	O
the	O
parent	B-Operating_System
process	I-Operating_System
of	O
a	O
daemon	B-Operating_System
is	O
often	O
,	O
but	O
not	O
always	O
,	O
the	O
init	B-Operating_System
process	O
.	O
</s>
<s>
A	O
daemon	B-Operating_System
is	O
usually	O
created	O
either	O
by	O
a	O
process	O
forking	B-Language
a	O
child	O
process	O
and	O
then	O
immediately	O
exiting	B-Operating_System
,	O
thus	O
causing	O
init	B-Operating_System
to	O
adopt	O
the	O
child	O
process	O
,	O
or	O
by	O
the	O
init	B-Operating_System
process	O
directly	O
launching	O
the	O
daemon	B-Operating_System
.	O
</s>
<s>
In	O
addition	O
,	O
a	O
daemon	B-Operating_System
launched	O
by	O
forking	B-Language
and	O
exiting	B-Operating_System
typically	O
must	O
perform	O
other	O
operations	O
,	O
such	O
as	O
dissociating	O
the	O
process	O
from	O
any	O
controlling	O
terminal	B-Device
(	O
tty	B-Device
)	O
.	O
</s>
<s>
Such	O
procedures	O
are	O
often	O
implemented	O
in	O
various	O
convenience	O
routines	O
such	O
as	O
daemon(3 )	O
in	O
Unix	B-Application
.	O
</s>
<s>
Systems	O
often	O
start	O
daemons	B-Operating_System
at	O
boot	B-Operating_System
time	I-Operating_System
that	O
will	O
respond	O
to	O
network	O
requests	O
,	O
hardware	O
activity	O
,	O
or	O
other	O
programs	O
by	O
performing	O
some	O
task	O
.	O
</s>
<s>
Daemons	B-Operating_System
such	O
as	O
cron	B-General_Concept
may	O
also	O
perform	O
defined	O
tasks	O
at	O
scheduled	O
times	O
.	O
</s>
<s>
According	O
to	O
Fernando	O
J	O
.	O
Corbató	O
,	O
who	O
worked	O
on	O
Project	O
MAC	O
in	O
1963	O
,	O
his	O
team	O
was	O
the	O
first	O
to	O
use	O
the	O
term	O
daemon	B-Operating_System
,	O
inspired	O
by	O
Maxwell	O
's	O
demon	B-Operating_System
,	O
an	O
imaginary	O
agent	O
in	O
physics	O
and	O
thermodynamics	O
that	O
helped	O
to	O
sort	O
molecules	O
,	O
stating	O
,	O
"	O
We	O
fancifully	O
began	O
to	O
use	O
the	O
word	O
daemon	B-Operating_System
to	O
describe	O
background	B-Operating_System
processes	I-Operating_System
that	O
worked	O
tirelessly	O
to	O
perform	O
system	O
chores	O
"	O
.	O
</s>
<s>
Unix	B-Application
systems	I-Application
inherited	O
this	O
terminology	O
.	O
</s>
<s>
Maxwell	O
's	O
demon	B-Operating_System
is	O
consistent	O
with	O
Greek	O
mythology	O
's	O
interpretation	O
of	O
a	O
daemon	B-Operating_System
as	O
a	O
supernatural	O
being	O
working	O
in	O
the	O
background	O
.	O
</s>
<s>
In	O
the	O
general	O
sense	O
,	O
daemon	B-Operating_System
is	O
an	O
older	O
form	O
of	O
the	O
word	O
"	O
demon	B-Operating_System
"	O
,	O
from	O
the	O
Greek	O
δαίμων	O
.	O
</s>
<s>
In	O
the	O
Unix	B-Application
System	I-Application
Administration	O
Handbook	O
Evi	O
Nemeth	O
states	O
the	O
following	O
about	O
daemons	B-Operating_System
:	O
</s>
<s>
A	O
further	O
characterization	O
of	O
the	O
mythological	O
symbolism	O
is	O
that	O
a	O
daemon	B-Operating_System
is	O
something	O
that	O
is	O
not	O
visible	O
yet	O
is	O
always	O
present	O
and	O
working	O
its	O
will	O
.	O
</s>
<s>
In	O
the	O
Theages	O
,	O
attributed	O
to	O
Plato	B-Operating_System
,	O
Socrates	O
describes	O
his	O
own	O
personal	O
daemon	B-Operating_System
to	O
be	O
something	O
like	O
the	O
modern	O
concept	O
of	O
a	O
moral	O
conscience	O
:	O
"	O
The	O
favour	O
of	O
the	O
gods	O
has	O
given	O
me	O
a	O
marvelous	O
gift	O
,	O
which	O
has	O
never	O
left	O
me	O
since	O
my	O
childhood	O
.	O
</s>
<s>
In	O
modern	O
usage	O
,	O
the	O
word	O
daemon	B-Operating_System
is	O
pronounced	O
.	O
</s>
<s>
Alternative	O
terms	O
for	O
daemon	B-Operating_System
are	O
service	O
(	O
used	O
in	O
Windows	O
,	O
from	O
Windows	B-Device
NT	I-Device
onwards	O
,	O
and	O
later	O
also	O
in	O
Linux	B-Application
)	O
,	O
started	O
task	O
(	O
IBM	B-Application
z/OS	I-Application
)	O
,	O
and	O
ghost	O
job	O
(	O
XDS	O
UTS	B-Operating_System
)	O
.	O
</s>
<s>
Daemons	B-Operating_System
that	O
connect	O
to	O
a	O
computer	O
network	O
are	O
examples	O
of	O
network	B-General_Concept
services	I-General_Concept
.	O
</s>
<s>
In	O
a	O
strictly	O
technical	O
sense	O
,	O
a	O
Unix-like	O
system	O
process	O
is	O
a	O
daemon	B-Operating_System
when	O
its	O
parent	B-Operating_System
process	I-Operating_System
terminates	B-Operating_System
and	O
the	O
daemon	B-Operating_System
is	O
assigned	O
the	O
init	B-Operating_System
process	O
(	O
process	O
number	O
1	O
)	O
as	O
its	O
parent	B-Operating_System
process	I-Operating_System
and	O
has	O
no	O
controlling	O
terminal	B-Device
.	O
</s>
<s>
However	O
,	O
more	O
generally	O
,	O
a	O
daemon	B-Operating_System
may	O
be	O
any	O
background	B-Operating_System
process	I-Operating_System
,	O
whether	O
a	O
child	O
of	O
the	O
init	B-Operating_System
process	O
or	O
not	O
.	O
</s>
<s>
On	O
a	O
Unix-like	O
system	O
,	O
the	O
common	O
method	O
for	O
a	O
process	O
to	O
become	O
a	O
daemon	B-Operating_System
,	O
when	O
the	O
process	O
is	O
started	O
from	O
the	O
command	B-Application
line	I-Application
or	O
from	O
a	O
startup	O
script	O
such	O
as	O
an	O
init	B-Operating_System
script	O
or	O
a	O
SystemStarter	B-Operating_System
script	O
,	O
involves	O
:	O
</s>
<s>
Executing	O
as	O
a	O
background	B-Operating_System
task	I-Operating_System
by	O
forking	B-Language
and	O
exiting	B-Operating_System
(	O
in	O
the	O
parent	O
"	O
half	O
"	O
of	O
the	O
fork	B-Language
)	O
.	O
</s>
<s>
This	O
allows	O
daemon	B-Operating_System
's	O
parent	O
(	O
shell	O
or	O
startup	O
process	O
)	O
to	O
receive	O
exit	O
notification	O
and	O
continue	O
its	O
normal	O
execution	O
.	O
</s>
<s>
Dissociating	O
from	O
the	O
controlling	O
tty	B-Device
.	O
</s>
<s>
Creating	O
a	O
new	O
session	O
and	O
becoming	O
the	O
session	B-Operating_System
leader	I-Operating_System
of	O
that	O
session	O
.	O
</s>
<s>
Becoming	O
a	O
process	B-Operating_System
group	I-Operating_System
leader	I-Operating_System
.	O
</s>
<s>
If	O
the	O
daemon	B-Operating_System
wants	O
to	O
ensure	O
that	O
it	O
will	O
not	O
acquire	O
a	O
new	O
controlling	O
tty	B-Device
even	O
by	O
accident	O
(	O
which	O
happens	O
when	O
a	O
session	B-Operating_System
leader	I-Operating_System
without	O
a	O
controlling	O
tty	B-Device
opens	O
a	O
free	O
tty	B-Device
)	O
,	O
it	O
may	O
fork	B-Language
and	O
exit	O
again	O
.	O
</s>
<s>
This	O
means	O
that	O
it	O
is	O
no	O
longer	O
a	O
session	B-Operating_System
leader	I-Operating_System
in	O
the	O
new	O
session	O
,	O
and	O
cannot	O
acquire	O
a	O
controlling	O
tty	B-Device
.	O
</s>
<s>
Setting	O
the	O
root	B-Application
directory	I-Application
(	O
)	O
as	O
the	O
current	B-Application
working	I-Application
directory	I-Application
so	O
that	O
the	O
process	O
does	O
not	O
keep	O
any	O
directory	O
in	O
use	O
that	O
may	O
be	O
on	O
a	O
mounted	B-Application
file	O
system	O
(	O
allowing	O
it	O
to	O
be	O
unmounted	O
)	O
.	O
</s>
<s>
Changing	O
the	O
umask	O
to	O
0	O
to	O
allow	O
open( )	O
,	O
creat( )	O
,	O
and	O
other	O
operating	B-General_Concept
system	I-General_Concept
calls	O
to	O
provide	O
their	O
own	O
permission	O
masks	O
and	O
not	O
to	O
depend	O
on	O
the	O
umask	O
of	O
the	O
caller	O
.	O
</s>
<s>
Redirecting	O
file	B-Application
descriptors	I-Application
0	O
,	O
1	O
and	O
2	O
for	O
the	O
standard	B-Operating_System
streams	I-Operating_System
(	O
stdin	O
,	O
stdout	O
and	O
stderr	O
)	O
to	O
or	O
a	O
logfile	B-Application
,	O
and	O
closing	O
all	O
the	O
other	O
file	B-Application
descriptors	I-Application
inherited	O
from	O
the	O
parent	B-Operating_System
process	I-Operating_System
.	O
</s>
<s>
If	O
the	O
process	O
is	O
started	O
by	O
a	O
super-server	B-Protocol
daemon	B-Operating_System
,	O
such	O
as	O
,	O
,	O
or	O
,	O
the	O
super-server	B-Protocol
daemon	B-Operating_System
will	O
perform	O
those	O
functions	O
for	O
the	O
process	O
,	O
except	O
for	O
old-style	O
daemons	B-Operating_System
not	O
converted	O
to	O
run	O
under	O
and	O
specified	O
as	O
and	O
"	O
multi-threaded	O
"	O
datagram	O
servers	O
under	O
.	O
</s>
<s>
In	O
the	O
Microsoft	B-Device
DOS	I-Device
environment	O
,	O
daemon-like	O
programs	O
were	O
implemented	O
as	O
terminate-and-stay-resident	O
programs	O
(	O
TSR	O
)	O
.	O
</s>
<s>
On	O
Microsoft	B-Device
Windows	I-Device
NT	I-Device
systems	O
,	O
programs	O
called	O
Windows	O
services	O
perform	O
the	O
functions	O
of	O
daemons	B-Operating_System
.	O
</s>
<s>
They	O
run	O
as	O
processes	O
,	O
usually	O
do	O
not	O
interact	O
with	O
the	O
monitor	O
,	O
keyboard	O
,	O
and	O
mouse	O
,	O
and	O
may	O
be	O
launched	O
by	O
the	O
operating	B-General_Concept
system	I-General_Concept
at	O
boot	B-Operating_System
time	I-Operating_System
.	O
</s>
<s>
In	O
Windows	B-Application
2000	I-Application
and	O
later	O
versions	O
,	O
Windows	O
services	O
are	O
configured	O
and	O
manually	O
started	O
and	O
stopped	O
using	O
the	O
Control	B-Operating_System
Panel	I-Operating_System
,	O
a	O
dedicated	O
control/configuration	O
program	O
,	O
the	O
Service	O
Controller	O
component	O
of	O
the	O
Service	O
Control	O
Manager	O
(	O
command	O
)	O
,	O
the	O
and	O
commands	O
or	O
the	O
PowerShell	B-Application
scripting	O
system	O
.	O
</s>
<s>
However	O
,	O
any	O
Windows	O
application	O
can	O
perform	O
the	O
role	O
of	O
a	O
daemon	B-Operating_System
,	O
not	O
just	O
a	O
service	O
,	O
and	O
some	O
Windows	O
daemons	B-Operating_System
have	O
the	O
option	O
of	O
running	O
as	O
a	O
normal	O
process	O
.	O
</s>
<s>
On	O
the	O
classic	B-Application
Mac	I-Application
OS	I-Application
,	O
optional	O
features	O
and	O
services	O
were	O
provided	O
by	O
files	O
loaded	O
at	O
startup	O
time	O
that	O
patched	O
the	O
operating	B-General_Concept
system	I-General_Concept
;	O
these	O
were	O
known	O
as	O
system	B-Operating_System
extensions	I-Operating_System
and	O
control	B-Operating_System
panels	I-Operating_System
.	O
</s>
<s>
Later	O
versions	O
of	O
classic	B-Application
Mac	I-Application
OS	I-Application
augmented	O
these	O
with	O
fully	O
fledged	O
faceless	O
background	O
applications	O
:	O
regular	O
applications	O
that	O
ran	O
in	O
the	O
background	O
.	O
</s>
<s>
To	O
the	O
user	O
,	O
these	O
were	O
still	O
described	O
as	O
regular	O
system	B-Operating_System
extensions	I-Operating_System
.	O
</s>
<s>
macOS	B-Application
,	O
which	O
is	O
a	O
Unix	B-Application
system	I-Application
,	O
uses	O
daemons	B-Operating_System
but	O
uses	O
the	O
term	O
"	O
services	O
"	O
to	O
designate	O
software	O
that	O
performs	O
functions	O
selected	O
from	O
the	O
Services	O
menu	O
,	O
rather	O
than	O
using	O
that	O
term	O
for	O
daemons	B-Operating_System
,	O
as	O
Windows	O
does	O
.	O
</s>
