6 #include <sys/featuretest.h>
8 /* The <sys/wait.h> header contains macros related to wait(). The value
9 * returned by wait() and waitpid() depends on whether the process
10 * terminated by an exit() call, was killed by a signal, or was stopped
11 * due to job control, as follows:
14 * +---------------------+
15 * exit(status) | status | 0 |
16 * +---------------------+
17 * killed by signal | 0 | signal |
18 * +---------------------+
19 * stopped (job control) | signal | 0177 |
20 * +---------------------+
24 * Macros to test the exit status returned by wait
25 * and extract the relevant values.
28 #define _LOW(v) ( (v) & 0377)
29 #define _HIGH(v) ( ((v) >> 8) & 0377)
31 #define WIFEXITED(s) (_LOW(s) == 0) /* normal exit */
32 #define WEXITSTATUS(s) (_HIGH(s)) /* exit status */
33 #define WTERMSIG(s) (_LOW(s) & 0177) /* sig value */
34 #define WIFSIGNALED(s) ((((unsigned int)(s)-1) & 0xFFFFU) < 0xFFU) /* signaled */
35 #define WIFSTOPPED(s) (_LOW(s) == 0177) /* stopped */
36 #define WSTOPSIG(s) (_HIGH(s) & 0377) /* stop signal */
39 * Option bits for the third argument of waitpid. WNOHANG causes the
40 * wait to not hang if there are no stopped or terminated processes, rather
41 * returning an error indication in this case (pid==0). WUNTRACED
42 * indicates that the caller should receive status about untraced children
43 * which stop due to signals. If children are stopped and a wait without
44 * this option is done, it is as though they were still running... nothing
45 * about them is returned.
47 #define WNOHANG 0x00000001 /* don't hang in wait */
48 #define WUNTRACED 0x00000002 /* tell about stopped,
51 /* POSIX extensions and 4.2/4.3 compatibility: */
54 * Tokens for special values of the "pid" parameter to waitpid.
56 #define WAIT_ANY (-1) /* any process */
57 #define WAIT_MYPGRP 0 /* any process in my process group */
61 pid_t
waitpid(pid_t
, int *, int);
64 #endif /* !_SYS_WAIT_H_ */