WAIT(2) UNIX Programmer's Manual WAIT(2) NAME wait - wait for process to terminate SYNOPSIS wait(status) int *status; wait((int *) 0) DESCRIPTION _W_a_i_t causes its caller to delay until a signal is received or one of its child processes terminates. If any child has died since the last _w_a_i_t, return is immediate; if there are no children, return is immediate with the error bit set (resp. with a value of -1 returned). The normal return yields the process ID of the terminated child. In the case of several children several _w_a_i_t calls are needed to learn of all the deaths. If (int)_s_t_a_t_u_s is nonzero, the high byte of the word pointed to receives the low byte of the argument of _e_x_i_t when the child terminated. The low byte receives the termination status of the process. See _s_i_g_n_a_l(2) for a list of termina- tion statuses (signals); 0 status indicates normal termina- tion. A special status (0177) is returned for a stopped process which has not terminated and can be restarted. See _p_t_r_a_c_e(2). If the 0200 bit of the termination status is set, a core image of the process was produced by the system. If the parent process terminates without waiting on its children, the initialization process (process ID = 1) inher- its the children. RETURN VALUE If _w_a_i_t returns due to the receipt of a signal, a value of -1 is returned to the calling process and the _e_r_r_n_o is set to EINTR. If _w_a_i_t returns due to a stopped or terminated child process, the process ID of the child is returned to the calling process. Otherwise, a value of -1 is returned and _e_r_r_n_o is set to indicate the error. ERRORS _W_a_i_t will fail and return immediately if one or more of the following is true: [ECHILD] The calling process has no unwaited-for child processes. [EFAULT] The _s_t_a_t_u_s argument points to an address outside the process's allocated address space. Printed 5/22/83 1 WAIT(2) UNIX Programmer's Manual WAIT(2) SEE ALSO exit(2), fork(2), signal(2), wait2(2J) ASSEMBLER (wait = 7.) sys wait (process ID in r0) (status in r1) The high byte of the status is the low byte of r0 in the child at termination. Printed 5/22/83 2