EXIT(2) EXIT(2) NAME _exit, wait wait3 - terminate process, wait for child to terminate SYNOPSIS void _exit(status) int status; int wait(status) int *status; int wait((int *)0) #include <sys/vtimes.h> wait3(status, options, ch_vt) int *status; struct vtimes *ch_vt; DESCRIPTION _exit closes all the process's files and notifies the parent process when the parent executes wait. The low-order 8 bits of status are available to the parent process. The call never returns. The function exit(3), which is the normal means of terminat- ing a process, may cause cleanup actions before finally calling _exit. Therefore, _exit should be called to termi- nate a child process after a fork(2) to avoid flushing buf- fered output twice. Wait delays until a signal is received or until a child pro- cesses terminates or receives signal SIGSTOP. There is no delay if any child has died since the last wait, or if there are no extant children. The normal return yields the pro- cess id and status of one terminated child. The status of other children may be learned from further wait calls. If status is nonzero, wait sets *status = (s<<8)+t where s is the low 8 bits of status from the child's exit, if any, and t is the termination status of the child. See signal(2) for a list of termination statuses (signals); status 0 indi- cates normal termination, 0177 a (restartable) process stopped on SIGSTOP. If the 0200 bit of the termination sta- tus is set, a core image of the process was produced by the system. Wait3 is similar to wait. An option value of 1 prevents waiting for extant, non-stopped children and causes 0 to be returned if children exist but none have reportable status. EXIT(2) EXIT(2) If ch_vt is nonzero, resource usage data for the child are reported as by vtimes(2). If the parent process terminates without waiting on its children, they are inherited by process 1 (the initializa- tion process, init(8)). SEE ALSO fork(2), exit(3), signal(2), sh(1) DIAGNOSTICS wait, wait3: ECHILD BUGS If the argument to wait is bogus, the user program gets a memory fault rather than an EFAULT. The 0 third argument to wait3 is a required historical dreg.