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
- 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
- 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.