Home

WIFSTOPPED

WIFSTOPPED is a macro used in POSIX-compatible systems (notably Linux) to inspect the wait status of a child process. It is defined in sys/wait.h and is used after calls such as wait, waitpid, or waitid to determine whether a child has been stopped by a signal rather than having exited or been terminated by a signal.

When a wait-related call returns a status value, WIFSTOPPED(status) evaluates to nonzero if the child is currently

WIFSTOPPED is distinct from WIFEXITED and WIFSIGNALED, which indicate normal termination or termination by a signal,

In practice, programs that manage multiple processes, such as shells or debuggers, may use WIFSTOPPED alongside

Notes: WIFSTOPPED relies on the encoding of the wait status provided by the kernel. Proper handling typically

in
a
stopped
state.
If
this
is
the
case,
the
macro
WSTOPSIG(status)
can
be
used
to
obtain
the
signal
number
that
caused
the
stop.
This
is
commonly
seen
when
a
process
is
stopped
by
signals
such
as
SIGSTOP
or
SIGTSTP,
or
when
a
debugger
attaches
and
stops
the
process.
respectively.
A
stopped
child
remains
in
that
state
until
it
is
resumed
(for
example,
with
SIGCONT)
or
terminated.
other
status
macros
to
drive
control
logic.
To
observe
events
such
as
continuation
after
a
stop,
the
WCONTINUED
status
can
be
reported
when
the
waiting
call
is
issued
with
appropriate
flags
(for
example,
WCONTINUED
or
WUNTRACED
in
waitpid).
involves
checking
WIFSTOPPED
first,
then
using
WSTOPSIG
to
identify
the
stopping
signal,
and
handling
other
state
transitions
through
WEXITED,
WIFSIGNALED,
and
WIFCONTINUED
as
appropriate.