Home

WIFEXITEDstatus

WIFEXITEDstatus is a term referring to the use of the WIFEXITED macro in the POSIX wait/status mechanism. In POSIX systems, a process can wait for child processes and obtain a status value that encodes how the child terminated. WIFEXITED(status) is a macro defined in sys/wait.h that tests whether the child terminated normally by calling exit or _Exit. If WIFEXITED(status) is true, the exit status is obtained with WEXITSTATUS(status), which yields the value passed to exit or _Exit, typically in the range 0 to 255.

The WIFEXITED macro is part of a family of status macros used with wait, waitpid, or similar

Usage pattern commonly involves calling waitpid (or wait) to obtain a status value, then testing with WIFEXITED(status).

Notes:

- These macros are defined in <sys/wait.h> on POSIX-compliant systems.

- The status value is an int, and the interpretation of its bits is implementation-defined but standardized

- Windows and some non-POSIX environments may provide different mechanisms for child-process termination status.

See also: wait, waitpid, WIFSIGNALED, WIFSTOPPED, WEXITSTATUS, WTERMSIG.

interfaces.
Other
macros
include
WIFSIGNALED,
WIFSTOPPED,
WTERMSIG,
and
WEXITSTATUS.
Together,
they
allow
a
program
to
distinguish
between
normal
termination,
termination
due
to
a
signal,
or
being
stopped
for
tracing
or
debugging.
For
normal
termination,
WEXITSTATUS
gives
the
actual
exit
code;
for
signal-based
termination,
WTERMSIG
reveals
the
signal
number.
If
true,
a
programmer
can
retrieve
the
exit
code
via
WEXITSTATUS(status).
If
not,
other
macros
can
be
used
to
determine
whether
the
process
was
terminated
by
a
signal
or
stopped.
in
terms
of
these
macros.