Home

WSTOPSIGstatus

WSTOPSIG status refers to the WSTOPSIG macro, a part of the POSIX wait family used in conjunction with wait or waitpid. Defined in the header <sys/wait.h>, WSTOPSIG(status) returns the signal number that caused a traced or child process to stop. The macro yields a meaningful value only when the status indicates that the child has stopped.

In practice, a programmer first tests the status with WIFSTOPPED(status). If true, WSTOPSIG(status) provides the specific

Usage notes:

- Include the header <sys/wait.h>.

- Use WIFSTOPPED(status) to confirm the child is stopped before calling WSTOPSIG(status).

- The value returned by WSTOPSIG(status) is an int corresponding to a standard SIG* signal number as

Example (conceptual):

- pid, status;

- waitpid(-1, &status, WUNTRACED);

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

Related macros include WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, and WIFCONTINUED/WCONTINUED, which cover other termination and continuation scenarios.

signal
that
stopped
the
child,
typically
a
SIGSTOP,
SIGTSTP,
SIGTTIN,
or
other
stop
signal.
This
information
is
useful
in
implementing
job
control,
shells,
debuggers,
or
other
process-management
tools
that
need
to
react
to
a
stopped
process.
defined
by
signal.h.
WSTOPSIG
is
specifically
about
the
signal
responsible
for
stopping
a
process,
not
for
its
normal
exit
or
termination
by
a
signal.