Home

ExitStatus

ExitStatus is a representation of how a program or child process terminated. It encodes information about the outcome of execution, typically including an exit code that indicates success or failure and, on some systems, additional details such as termination by a signal.

In POSIX and Unix-like systems, the exit status is delivered to the parent process via wait or

Windows reports exit codes through the GetExitCodeProcess API. An exit code is a 32-bit value; zero typically

In programming languages there are language-specific representations. For example, Rust provides a type named ExitStatus in

Overall, exit status conveys whether a process finished cleanly and, if not, why it did not succeed.

waitpid.
The
status
value
is
examined
with
a
set
of
macros:
WIFEXITED
indicates
normal
termination,
WEXITSTATUS
yields
the
exit
code
(usually
in
the
range
0–255),
and
WIFSIGNALED
indicates
termination
by
a
signal,
with
WCOREDUMP
signaling
a
core
dump.
The
low
8
bits
generally
carry
the
exit
code,
while
other
bits
encode
the
reason
for
termination.
In
shells,
the
exit
status
of
the
most
recent
foreground
command
is
exposed
as
a
special
variable
(commonly
used
as
$?).
means
success,
but
specific
programs
define
nonzero
codes
to
indicate
particular
errors.
Because
Windows
and
POSIX
conventions
are
not
identical,
portable
interpretation
of
exit
statuses
must
be
careful.
the
standard
library
to
represent
the
exit
status
of
a
child
process
started
with
std::process.
The
code
method
returns
an
Option<i32>
with
the
exit
code
when
the
child
exited
normally.
On
Unix,
there
is
an
extension
trait
that
exposes
additional
details,
such
as
the
terminating
signal
and
whether
a
core
dump
occurred.
Programs
that
rely
on
exit
codes
should
handle
the
variability
across
platforms
by
checking
for
normal
exit
first
and
then
interpreting
the
code
accordingly.