wait(3) wait(3) NNAAMMEE wait - check child process status SSYYNNTTAAXX ##iinncclluuddee <> int wwaaiitt__nnoohhaanngg(&_w_s_t_a_t); int wwaaiitt__ssttoopp(&_w_s_t_a_t); int wwaaiitt__ssttooppnnoohhaanngg(&_w_s_t_a_t); int wwaaiitt__ppiidd(&_w_s_t_a_t,_p_i_d); int wwaaiitt__eexxiittccooddee(_w_s_t_a_t); int wwaaiitt__ccrraasshheedd(_w_s_t_a_t); int wwaaiitt__ssttooppppeedd(_w_s_t_a_t); int wwaaiitt__ssttooppssiigg(_w_s_t_a_t); int _p_i_d; int _w_s_t_a_t; DDEESSCCRRIIPPTTIIOONN wwaaiitt__nnoohhaanngg looks for zombies (child processes that have exited). If it sees a zombie, it eliminates the zombie, puts the zombie’s exit sta- tus into _w_s_t_a_t, and returns the zombie’s process ID. If there are sev- eral zombies, wwaaiitt__nnoohhaanngg picks one. If there are children but no zom- bies, wwaaiitt__nnoohhaanngg returns 0. If there are no children, wwaaiitt__nnoohhaanngg returns -1, setting eerrrrnnoo appropriately. wwaaiitt__ssttooppnnoohhaanngg is similar to wwaaiitt__nnoohhaanngg, but it also looks for chil- dren that have stopped. wwaaiitt__ssttoopp is similar to wwaaiitt__ssttooppnnoohhaanngg, but if there are children it will pause waiting for one of them to stop or exit. wwaaiitt__ppiidd waits for child process _p_i_d to exit. It eliminates any zombie that shows up in the meantime, discarding the exit status. wwaaiitt__ssttoopp and wwaaiitt__ppiidd retry upon eerrrroorr__iinnttrr. SSTTAATTUUSS PPAARRSSIINNGG If the child stopped, wwaaiitt__ssttooppppeedd is nonzero; wwaaiitt__ssttooppssiigg is the sig- nal that caused the child to stop. If the child exited by crashing, wwaaiitt__ssttooppppeedd is zero; wwaaiitt__ccrraasshheedd is nonzero. If the child exited normally, wwaaiitt__ssttooppppeedd is zero; wwaaiitt__ccrraasshheedd is zero; and wwaaiitt__eexxiittccooddee is the child’s exit code. SSEEEE AALLSSOO wait(2), error(3) wait(3)