#include <sys/wait.h>
sys/wait.h
enumidtype_t
[XSI] The type idtype_t shall be defined as an enumeration type whose
possible values shall include at least P_ALL, P_PID, and P_PGID.
| P_ALL | 0 | |
| P_PID | 1 | |
| P_PGID | 2 |
typedefidtype_t
typedef enum idtype_t idtype_t;
macroWNOHANG
Option bits for the third argument of wait4. WNOHANG causes the
wait to not hang if there are no stopped or terminated processes, rather
returning an error indication in this case (pid==0). WUNTRACED
indicates that the caller should receive status about untraced children
which stop due to signals. If children are stopped and a wait without
this option is done, it is as though they were still running... nothing
about them is returned.
#define WNOHANG 0x00000001
[XSI] no hang in wait/no child to reap
macro_W_INT
Macros to test the exit status returned by wait
and extract the relevant values.
#define _W_INT(w) (*(int *)&(w))
convert union wait to int
macroWCOREFLAG
#define WCOREFLAG 0200
macro_WSTATUS
These macros are permited, as they are in the implementation namespace
#define _WSTATUS(x) (_W_INT(x) & 0177)
macroWEXITSTATUS
[XSI] The <sys/wait.h> header shall define the following macros for
analysis of process status values
#define WEXITSTATUS(x) ((_W_INT(x) >> 8) & 0x000000ff)
macroWIFCONTINUED
#define WIFCONTINUED(x) (_WSTATUS(x) == _WSTOPPED && WSTOPSIG(x) == 0x13)
macroWIFSTOPPED
#define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED && WSTOPSIG(x) != 0x13)
macroWIFSIGNALED
#define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
macroW_EXITCODE
#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
macroW_STOPCODE
#define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED)
macroWEXITED
[XSI] The following symbolic constants shall be defined as possible
values for the fourth argument to waitid().
WNOHANG already defined for wait4()
WUNTRACED defined for wait4() but not for waitid()
#define WEXITED 0x00000004
[XSI] Processes which have exitted
macroWAIT_ANY
Tokens for special values of the "pid" parameter to wait4.
#define WAIT_ANY (-1)
any process
unionwait
Deprecated:
Structure of the information in the status word returned by wait4.
If w_stopval==_WSTOPPED, then the second structure describes
the information returned, else the first.
| int | w_status | used in syscall | ||||||||||||
| unnamed struct at sys/wait.h:199:2 | w_T | Terminated process status. | ||||||||||||
| ||||||||||||||
| unnamed struct at sys/wait.h:217:2 | w_S | Stopped process status. Returned only for traced children unless requested with the WUNTRACED option bit. | ||||||||||||
| ||||||||||||||
macrow_termsig
#define w_termsig w_T.w_Termsig
macrow_coredump
#define w_coredump w_T.w_Coredump
macrow_retcode
#define w_retcode w_T.w_Retcode
macrow_stopval
#define w_stopval w_S.w_Stopval
macrow_stopsig
#define w_stopsig w_S.w_Stopsig
functionwait
__DARWIN_ALIAS_C(wait) pid_t wait(int *)
man page · April 19, 1994
wait(2) — wait for process terminationfunctionwaitpid
__DARWIN_ALIAS_C(waitpid) pid_t waitpid(pid_t, int *, int)
man page · April 19, 1994
waitpid(2) — wait for process termination