BSD 3 development
[unix-history] / usr / man / man2 / wait.2
CommitLineData
e6817382
BJ
1.TH WAIT 2
2.SH NAME
3wait \- wait for process to terminate
4.SH SYNOPSIS
5.B wait(status)
6.br
7.B int *status;
8.PP
9.B wait(0)
10.SH DESCRIPTION
11.I Wait
12causes its caller to delay until a signal is received or
13one of its child
14processes terminates.
15If any child has died since the last
16.I wait,
17return is immediate;
18if there are no children, return is immediate with
19the error bit set
20(resp. with a value of \-1 returned).
21The normal return yields the process ID of the terminated child.
22In the case of several children several
23.I wait
24calls are needed
25to learn of all the deaths.
26.PP
27If
28.RI (int) status
29is nonzero, the high byte of the word pointed to
30receives the low byte of the
31argument of
32.I exit
33when the child terminated.
34The low byte
35receives the termination status
36of the process.
37See
38.IR signal (2)
39for a list of termination statuses (signals);
400 status indicates normal termination.
41A special status (0177) is returned for a stopped process
42which has not terminated and can be restarted.
43See
44.IR ptrace (2).
45If the 0200 bit of the termination status
46is set,
47a core image of the process was produced
48by the system.
49.PP
50If the parent process terminates without
51waiting on its children,
52the initialization process
53(process ID = 1)
54inherits the children.
55.SH "SEE ALSO"
56exit(2), fork(2), signal(2)
57.SH DIAGNOSTICS
58Returns
59\-1 if there are no children not previously waited for.
60.SH "ASSEMBLER (PDP-11)"
61(wait = 7.)
62.br
63.B sys wait
64.br
65(process ID in r0)
66.br
67(status in r1)
68.PP
69The high byte of the status is
70the low byte of r0 in the child at termination.