1 .\" Copyright (c) 1980 Regents of the University of California.
2 .\" All rights reserved. The Berkeley software License Agreement
3 .\" specifies the terms and conditions for redistribution.
5 .\" @(#)wait.2 6.2 (Berkeley) 6/30/85
7 .TH WAIT 2 "June 30, 1985"
10 wait, waitpid \- wait for process to terminate
14 #include <sys/types.h>
17 pid_t wait(int *\fIstatus\fP)
18 pid_t waitpid(pid_t \fIpid\fP, int *\fIstatus\fP, int \fIoptions\fP)
22 causes its caller to delay until a signal is received or
25 If any child has died since the last
27 return is immediate, returning the process id and
28 exit status of one of the terminated
30 If there are no children, return is immediate with
31 the value \-1 returned.
33 On return from a successful
37 is nonzero, and the high byte of
39 contains the low byte of the argument to
41 supplied by the child process;
44 contains the termination status of the process.
45 A more precise definition of the
50 can be called with a null pointer argument to indicate that no status need
54 provides an alternate interface for programs
55 that must not block when collecting the status
56 of child processes, or that wish to wait for
57 one particular child. The pid parameter is
58 the process ID of the child to wait for, \-1
61 parameter is defined as above. The
63 parameter is used to indicate the call should not block if
64 there are no processes that wish to report status (WNOHANG),
65 and/or that children of the current process that are stopped
66 due to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal should also have
67 their status reported (WUNTRACED). (Job control is not implemented for
68 MINIX 3, but these symbols and signals are.)
70 When the WNOHANG option is specified and no processes
71 wish to report status,
73 either returns 0 under some implementations, or \-1 with
78 (Under MINIX 3 it returns 0.)
79 The WNOHANG and WUNTRACED options may be combined by
84 .BI "wait(&" status ")"
86 .BI "waitpid(\-1, &" status ", 0)\fR."
90 for a list of termination statuses (signals);
91 0 status indicates normal termination.
92 A special status (0177) is returned for a stopped process
93 that has not terminated and can be restarted;
96 If the 0200 bit of the termination status
98 a core image of the process was produced
101 If the parent process terminates without
102 waiting on its children,
103 the initialization process
105 inherits the children.
108 defines a number of macros that operate on a status word:
110 .BI "WIFEXITED(" status ")"
113 .BI "WEXITSTATUS(" status ")"
114 Exit status if the process returned by a normal exit, zero otherwise.
116 .BI "WTERMSIG(" status ")"
117 Signal number if the process died by a signal, zero otherwise.
119 .BI "WIFSIGNALED(" status ")"
120 True if the process died by a signal.
122 .BI "WIFSTOPPED(" status ")"
123 True if the process is stopped. (Never true under MINIX 3.)
125 .BI "WSTOPSIG(" status ")"
126 Signal number of the signal that stopped the process.
128 If \fBwait\fP returns due to a stopped
129 or terminated child process, the process ID of the child
130 is returned to the calling process. Otherwise, a value of \-1
131 is returned and \fBerrno\fP is set to indicate the error.
134 returns \-1 if there are no children not previously waited for or if
135 the process that it wants to wait for doesn't exist.
138 returns 0 if WNOHANG is specified and there are no stopped or exited
139 children. (Under other implementations it may return \-1 instead. Portable
140 code should test for both possibilities.)
143 will fail and return immediately if one or more of the following
147 The calling process has no existing unwaited-for
151 The \fIstatus\fP argument points to an illegal address.
155 is called with the WNOHANG option and no child has exited yet. (Not under
156 MINIX 3, it'll return 0 in this case and leave