<s>
An	O
orphan	B-Operating_System
process	I-Operating_System
is	O
a	O
computer	B-Operating_System
process	I-Operating_System
whose	O
parent	B-Operating_System
process	I-Operating_System
has	O
finished	O
or	O
terminated	B-Operating_System
,	O
though	O
it	O
remains	O
running	O
itself	O
.	O
</s>
<s>
In	O
a	O
Unix-like	B-Operating_System
operating	I-Operating_System
system	I-Operating_System
any	O
orphaned	O
process	O
will	O
be	O
immediately	O
adopted	O
by	O
an	O
implementation-defined	O
system	B-Operating_System
process	I-Operating_System
:	O
the	O
kernel	O
sets	O
the	O
parent	O
to	O
this	O
process	O
.	O
</s>
<s>
Even	O
though	O
technically	O
the	O
process	O
has	O
a	O
system	B-Operating_System
process	I-Operating_System
as	O
its	O
parent	O
,	O
it	O
is	O
still	O
called	O
an	O
orphan	B-Operating_System
process	I-Operating_System
since	O
the	O
process	O
that	O
originally	O
created	O
it	O
no	O
longer	O
exists	O
.	O
</s>
<s>
In	O
other	O
systems	O
orphaned	O
processes	O
are	O
immediately	O
terminated	B-Operating_System
by	O
the	O
kernel	O
.	O
</s>
<s>
Most	O
Unix	O
systems	O
have	O
historically	O
used	O
init	O
as	O
the	O
system	B-Operating_System
process	I-Operating_System
to	O
which	O
orphans	O
are	O
reparented	O
,	O
but	O
in	O
modern	O
DragonFly	B-Application
BSD	I-Application
,	O
FreeBSD	B-Operating_System
,	O
and	O
Linux	O
systems	O
,	O
an	O
orphan	B-Operating_System
process	I-Operating_System
may	O
be	O
reparented	O
to	O
a	O
"	O
subreaper	O
"	O
process	O
instead	O
of	O
init	O
.	O
</s>
<s>
A	O
process	O
can	O
be	O
orphaned	O
unintentionally	O
,	O
such	O
as	O
when	O
the	O
parent	B-Operating_System
process	I-Operating_System
terminates	B-Operating_System
or	O
crashes	O
.	O
</s>
<s>
The	O
process	B-Operating_System
group	I-Operating_System
mechanism	O
in	O
most	O
Unix-like	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
can	O
be	O
used	O
to	O
help	O
protect	O
against	O
accidental	O
orphaning	O
,	O
where	O
in	O
coordination	O
with	O
the	O
user	O
's	O
shell	B-Application
will	O
try	O
to	O
terminate	B-Operating_System
all	O
the	O
child	O
processes	O
with	O
the	O
"	O
hangup	O
"	O
signal	O
(	O
SIGHUP	B-General_Concept
)	O
,	O
rather	O
than	O
letting	O
them	O
continue	O
to	O
run	O
as	O
orphans	O
.	O
</s>
<s>
More	O
precisely	O
,	O
as	O
part	O
of	O
job	B-Operating_System
control	I-Operating_System
,	O
when	O
the	O
shell	B-Application
exits	O
,	O
because	O
it	O
is	O
the	O
"	O
session	B-Operating_System
leader	I-Operating_System
"	O
(	O
its	O
session	O
id	O
equals	O
its	O
process	O
id	O
)	O
,	O
the	O
corresponding	O
login	B-Operating_System
session	I-Operating_System
ends	O
,	O
and	O
the	O
shell	B-Application
sends	O
SIGHUP	B-General_Concept
to	O
all	O
its	O
jobs	O
(	O
internal	O
representation	O
of	O
process	B-Operating_System
groups	I-Operating_System
)	O
.	O
</s>
<s>
It	O
is	O
sometimes	O
desirable	O
to	O
intentionally	O
orphan	O
a	O
process	O
,	O
usually	O
to	O
allow	O
a	O
long-running	O
job	O
to	O
complete	O
without	O
further	O
user	O
attention	O
,	O
or	O
to	O
start	O
an	O
indefinitely	O
running	O
service	O
or	O
agent	O
;	O
such	O
processes	O
(	O
without	O
an	O
associated	O
session	O
)	O
are	O
known	O
as	O
daemons	B-Operating_System
,	O
particularly	O
if	O
they	O
are	O
indefinitely	O
running	O
.	O
</s>
<s>
A	O
low-level	O
approach	O
is	O
to	O
fork	B-Language
twice	O
,	O
running	O
the	O
desired	O
process	O
in	O
the	O
grandchild	O
,	O
and	O
immediately	O
terminating	O
the	O
child	O
.	O
</s>
<s>
Higher-level	O
alternatives	O
circumvent	O
the	O
shell	B-Application
's	O
hangup	O
handling	O
,	O
either	O
telling	O
the	O
child	O
process	O
to	O
ignore	O
SIGHUP	B-General_Concept
(	O
by	O
using	O
nohup	B-Device
)	O
,	O
or	O
removing	O
the	O
job	O
from	O
the	O
job	O
table	O
or	O
telling	O
the	O
shell	B-Application
to	O
not	O
send	O
SIGHUP	B-General_Concept
on	O
session	O
end	O
(	O
by	O
using	O
disown	B-Application
in	O
either	O
case	O
)	O
.	O
</s>
<s>
In	O
any	O
event	O
,	O
the	O
session	O
id	O
(	O
process	O
id	O
of	O
the	O
session	B-Operating_System
leader	I-Operating_System
,	O
the	O
shell	B-Application
)	O
does	O
not	O
change	O
,	O
and	O
the	O
process	O
id	O
of	O
the	O
session	O
that	O
has	O
ended	O
is	O
still	O
in	O
use	O
until	O
all	O
orphaned	O
processes	O
either	O
terminate	B-Operating_System
or	O
change	O
session	O
id	O
(	O
by	O
starting	O
a	O
new	O
session	O
via	O
setsid(2 )	O
)	O
.	O
</s>
<s>
To	O
simplify	O
system	O
administration	O
,	O
it	O
is	O
often	O
desirable	O
to	O
use	O
a	O
service	B-Language
wrapper	I-Language
so	O
that	O
processes	O
not	O
designed	O
to	O
be	O
used	O
as	O
services	O
respond	O
correctly	O
to	O
system	O
signals	O
.	O
</s>
<s>
An	O
alternative	O
to	O
keep	O
processes	O
running	O
without	O
orphaning	O
them	O
is	O
to	O
use	O
a	O
terminal	O
multiplexer	O
and	O
run	O
the	O
processes	O
in	O
a	O
detached	O
session	O
(	O
or	O
a	O
session	O
that	O
becomes	O
detached	O
)	O
,	O
so	O
the	O
session	O
is	O
not	O
terminated	B-Operating_System
and	O
the	O
process	O
is	O
not	O
orphaned	O
.	O
</s>
<s>
However	O
,	O
there	O
are	O
several	O
solutions	O
to	O
the	O
orphan	B-Operating_System
process	I-Operating_System
problem	O
:	O
</s>
