<s>
On	O
many	O
computer	B-General_Concept
operating	I-General_Concept
systems	I-General_Concept
,	O
a	O
computer	B-Operating_System
process	I-Operating_System
terminates	B-Operating_System
its	O
execution	B-General_Concept
by	O
making	O
an	O
exit	O
system	B-Operating_System
call	I-Operating_System
.	O
</s>
<s>
More	O
generally	O
,	O
an	O
exit	O
in	O
a	O
multithreading	B-Operating_System
environment	O
means	O
that	O
a	O
thread	B-Operating_System
of	I-Operating_System
execution	I-Operating_System
has	O
stopped	O
running	O
.	O
</s>
<s>
For	O
resource	O
management	O
,	O
the	O
operating	B-General_Concept
system	I-General_Concept
reclaims	O
resources	B-General_Concept
(	O
memory	B-General_Concept
,	O
files	B-Operating_System
,	O
etc	O
.	O
)	O
</s>
<s>
that	O
were	O
used	O
by	O
the	O
process	B-Operating_System
.	O
</s>
<s>
The	O
process	B-Operating_System
is	O
said	O
to	O
be	O
a	O
dead	O
process	B-Operating_System
after	O
it	O
terminates	B-Operating_System
.	O
</s>
<s>
Under	O
Unix	B-Application
and	O
Unix-like	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
,	O
a	O
process	B-Operating_System
is	O
started	O
when	O
its	O
parent	B-Operating_System
process	I-Operating_System
executes	O
a	O
fork	B-Language
system	B-Operating_System
call	I-Operating_System
.	O
</s>
<s>
The	O
parent	B-Operating_System
process	I-Operating_System
may	O
then	O
wait	B-Operating_System
for	O
the	O
child	B-Operating_System
process	I-Operating_System
to	O
terminate	B-Operating_System
,	O
or	O
may	O
continue	O
execution	B-General_Concept
(	O
possibly	O
forking	O
off	O
other	O
child	O
processes	O
)	O
.	O
</s>
<s>
When	O
the	O
child	B-Operating_System
process	I-Operating_System
terminates	B-Operating_System
(	O
"	O
dies	O
"	O
)	O
,	O
either	O
normally	O
by	O
calling	O
exit	O
,	O
or	O
abnormally	B-Application
due	O
to	O
a	O
fatal	B-Error_Name
exception	I-Error_Name
or	O
signal	B-Operating_System
(	O
e.g.	O
,	O
SIGTERM	B-General_Concept
,	O
SIGINT	B-General_Concept
,	O
SIGKILL	B-General_Concept
)	O
,	O
an	O
exit	B-Operating_System
status	I-Operating_System
is	O
returned	O
to	O
the	O
operating	B-General_Concept
system	I-General_Concept
and	O
a	O
SIGCHLD	B-General_Concept
signal	B-Operating_System
is	O
sent	O
to	O
the	O
parent	B-Operating_System
process	I-Operating_System
.	O
</s>
<s>
The	O
exit	B-Operating_System
status	I-Operating_System
can	O
then	O
be	O
retrieved	O
by	O
the	O
parent	B-Operating_System
process	I-Operating_System
via	O
the	O
wait	B-Operating_System
system	B-Operating_System
call	I-Operating_System
.	O
</s>
<s>
Most	O
operating	B-General_Concept
systems	I-General_Concept
allow	O
the	O
terminating	O
process	B-Operating_System
to	O
provide	O
a	O
specific	O
exit	B-Operating_System
status	I-Operating_System
to	O
the	O
system	O
,	O
which	O
is	O
made	O
available	O
to	O
the	O
parent	B-Operating_System
process	I-Operating_System
.	O
</s>
<s>
Typically	O
this	O
is	O
an	O
integer	O
value	O
,	O
although	O
some	O
operating	B-General_Concept
systems	I-General_Concept
(	O
e.g.	O
,	O
Plan	B-Operating_System
9	I-Operating_System
from	I-Operating_System
Bell	I-Operating_System
Labs	I-Operating_System
)	O
allow	O
a	O
character	O
string	O
to	O
be	O
returned	O
.	O
</s>
<s>
Systems	O
returning	O
an	O
integer	O
value	O
commonly	O
use	O
a	O
zero	O
value	O
to	O
indicate	O
successful	O
execution	B-General_Concept
and	O
non-zero	O
values	O
to	O
indicate	O
error	O
conditions	O
.	O
</s>
<s>
Other	O
systems	O
(	O
e.g.	O
,	O
OpenVMS	B-Operating_System
)	O
use	O
even-numbered	O
values	O
for	O
success	O
and	O
odd	O
values	O
for	O
errors	O
.	O
</s>
<s>
Still	O
other	O
systems	O
(	O
e.g.	O
,	O
IBM	B-Application
z/OS	I-Application
and	O
its	O
predecessors	O
)	O
use	O
ranges	O
of	O
integer	O
values	O
to	O
indicate	O
success	O
,	O
warning	O
,	O
and	O
error	O
completion	O
results	O
.	O
</s>
<s>
The	O
exit	O
operation	O
typically	O
performs	O
clean-up	O
operations	O
within	O
the	O
process	B-Operating_System
space	O
before	O
returning	O
control	O
back	O
to	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
Some	O
systems	O
and	O
programming	O
languages	O
allow	O
user	O
subroutines	O
to	O
be	O
registered	O
so	O
that	O
they	O
are	O
invoked	O
at	O
program	O
termination	O
before	O
the	O
process	B-Operating_System
actually	O
terminates	B-Operating_System
for	O
good	O
.	O
</s>
<s>
As	O
the	O
final	O
step	O
of	O
termination	O
,	O
a	O
primitive	O
system	O
exit	O
call	O
is	O
invoked	O
,	O
informing	O
the	O
operating	B-General_Concept
system	I-General_Concept
that	O
the	O
process	B-Operating_System
has	O
terminated	O
and	O
allows	O
it	O
to	O
reclaim	O
the	O
resources	B-General_Concept
used	O
by	O
the	O
process	B-Operating_System
.	O
</s>
<s>
It	O
is	O
sometimes	O
possible	O
to	O
bypass	O
the	O
usual	O
cleanup	O
;	O
C99	B-Language
offers	O
the	O
_exit( )	O
function	O
which	O
terminates	B-Operating_System
the	O
current	O
process	B-Operating_System
without	O
any	O
extra	O
program	O
clean-up	O
.	O
</s>
<s>
This	O
may	O
be	O
used	O
,	O
for	O
example	O
,	O
in	O
a	O
fork-exec	B-Operating_System
routine	O
when	O
the	O
exec	B-Operating_System
call	O
fails	O
to	O
replace	O
the	O
child	B-Operating_System
process	I-Operating_System
;	O
calling	O
atexit	O
routines	O
would	O
erroneously	O
release	O
resources	B-General_Concept
belonging	O
to	O
the	O
parent	O
.	O
</s>
<s>
Some	O
operating	B-General_Concept
systems	I-General_Concept
handle	O
a	O
child	B-Operating_System
process	I-Operating_System
whose	O
parent	B-Operating_System
process	I-Operating_System
has	O
terminated	O
in	O
a	O
special	O
manner	O
.	O
</s>
<s>
Such	O
an	O
orphan	B-Operating_System
process	I-Operating_System
becomes	O
a	O
child	O
of	O
a	O
special	O
root	B-Operating_System
process	I-Operating_System
,	O
which	O
then	O
waits	O
for	O
the	O
child	B-Operating_System
process	I-Operating_System
to	O
terminate	B-Operating_System
.	O
</s>
<s>
Likewise	O
,	O
a	O
similar	O
strategy	O
is	O
used	O
to	O
deal	O
with	O
a	O
zombie	B-Operating_System
process	I-Operating_System
,	O
which	O
is	O
a	O
child	B-Operating_System
process	I-Operating_System
that	O
has	O
terminated	O
but	O
whose	O
exit	B-Operating_System
status	I-Operating_System
is	O
ignored	O
by	O
its	O
parent	B-Operating_System
process	I-Operating_System
.	O
</s>
<s>
Such	O
a	O
process	B-Operating_System
becomes	O
the	O
child	O
of	O
a	O
special	O
parent	B-Operating_System
process	I-Operating_System
,	O
which	O
retrieves	O
the	O
child	O
's	O
exit	B-Operating_System
status	I-Operating_System
and	O
allows	O
the	O
operating	B-General_Concept
system	I-General_Concept
to	O
complete	O
the	O
termination	O
of	O
the	O
dead	O
process	B-Operating_System
.	O
</s>
<s>
Dealing	O
with	O
these	O
special	O
cases	O
keeps	O
the	O
system	B-Operating_System
process	I-Operating_System
table	O
in	O
a	O
consistent	O
state	O
.	O
</s>
<s>
The	O
following	O
programs	O
terminate	B-Operating_System
and	O
return	O
a	O
success	O
exit	B-Operating_System
status	I-Operating_System
to	O
the	O
system	O
.	O
</s>
<s>
C	B-Language
:	O
</s>
<s>
}	O
C++	B-Language
:	O
</s>
<s>
COBOL	B-Application
:	O
</s>
<s>
Fortran	B-Application
:	O
</s>
<s>
Java	B-Language
:	O
</s>
<s>
Pascal	B-Application
:	O
</s>
<s>
DR-DOS	B-Application
batch	O
file	O
:	O
</s>
<s>
Perl	B-Language
:	O
</s>
<s>
PHP	B-Application
:	O
</s>
<s>
Python	B-Language
:	O
</s>
<s>
Unix	B-Application
shell	I-Application
:	O
</s>
<s>
DOS	B-Device
assembly	B-Language
:	O
</s>
<s>
Some	O
programmers	O
may	O
prepare	O
everything	O
for	O
INT	B-Application
21h	I-Application
at	O
once	O
:	O
</s>
<s>
Linux	B-Application
32-bit	O
x86	B-Operating_System
Assembly	B-Language
:	O
</s>
<s>
On	O
Windows	O
,	O
a	O
program	O
can	O
terminate	B-Operating_System
itself	O
by	O
calling	O
ExitProcess	O
or	O
RtlExitUserProcess	O
function	O
.	O
</s>
