Home

WUNTRACED

WUNTRACED is a flag used with POSIX wait-related system calls, notably waitpid and waitid. It requests that the call also report on children that have stopped due to a signal, in addition to those that have terminated. The flag is defined in the system header sys/wait.h and is combined with other options by using a bitwise OR when calling waitpid or waitid.

When WUNTRACED is set, a waitpid or waitid call will return for a child that has stopped

Usage example in C:

- int status;

- pid_t p = waitpid(-1, &status, WUNTRACED);

- if (WIFSTOPPED(status)) { int sig = WSTOPSIG(status); /* handle stop */ }

Compatibility and notes:

- WUNTRACED is part of the POSIX wait family of options and is commonly available on Unix-like systems,

- It is used by debuggers, shells, and other tools that need visibility into not only terminated

In summary, WUNTRACED extends the information returned by waitpid and waitid to include stopped child processes,

(for
example,
due
to
a
signal
such
as
SIGSTOP
or
a
debugger-related
stop).
The
resulting
status
can
be
inspected
with
macros
such
as
WIFSTOPPED
to
confirm
the
stop
condition,
and
WSTOPSIG
to
determine
the
signal
that
caused
the
stop.
If
WUNTRACED
is
not
set,
the
call
typically
returns
only
for
terminated
children.
The
WUNTRACED
flag
may
be
used
together
with
WCONTINUED
to
also
receive
notifications
when
a
stopped
child
continues.
including
Linux,
BSD
variants,
and
macOS.
children
but
also
those
that
have
been
stopped
by
signals.
enabling
more
precise
process
control
and
monitoring
in
user-space
programs.