


_O_n_l_i_n_e _M_a_n_u_a_l             System Calls                    wait(2)



NNNNAAAAMMMMEEEE
     wait, wait3 - wait for process to terminate

SSSSYYYYNNNNTTTTAAAAXXXX
     ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////wwwwaaaaiiiitttt....hhhh>>>>
     #include <signal.h>

     ppppiiiidddd ==== wwwwaaaaiiiitttt((((ssssttttaaaattttuuuussss))))
     int pid;
     union wait *status;

     ppppiiiidddd ==== wwwwaaaaiiiitttt((((0000))))
     int pid;

     ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ttttiiiimmmmeeee....hhhh>>>>
     #include <sys/resource.h>

     ppppiiiidddd ==== wwwwaaaaiiiitttt3333((((ssssttttaaaattttuuuussss,,,, ooooppppttttiiiioooonnnnssss,,,, rrrruuuussssaaaaggggeeee))))
     int pid;
     union wait *status;
     int options;
     struct rusage *rusage;

DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
     The _w_a_i_t call causes the caller to delay until either a sig-
     nal is received or a child process terminates.  Return is
     immediate if any child died since the last _w_a_i_t.  In this
     case, a terminated child's process id and exit status are
     returned.  If there are no children, an immediate error
     return (-1 return value) occurs.

     On successful return, status.w_retcode contains the low byte
     of the argument to _e_x_i_t supplied by the child process;
     status.w_termsig _c_o_n_t_a_i_n_s _t_h_e _c_h_i_l_d'_s _t_e_r_m_i_n_a_t_i_o_n _s_t_a_t_u_s
     (_s_i_g_n_a_l _n_u_m_b_e_r); _a_n_d _s_t_a_t_u_s._w__s_i_g_c_o_d_e contains the signal
     subclass code.  Refer to the sys/wait.h _h_e_a_d_e_r _f_i_l_e _o_n _y_o_u_r
     _s_y_s_t_e_m.

     _w_a_i_t_3 provides an alternate interface for programs which
     must not block when collecting the status of child
     processes.  The _s_t_a_t_u_s parameter is defined as above.  The
     _o_p_t_i_o_n_s parameter is used to indicate the call should not
     block if no processes wish to report status (WNOHANG),
     and/or that only children of the current process which are
     stopped due to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP sig-
     nal should have their status reported (WUNTRACED).  If
     _r_u_s_a_g_e is non-zero, a summary of the resources used by the
     terminated process and all its children is returned.  (This
     information is currently not available for stopped
     processes).

     When the WNOHANG option is specified and no processes wish
     to report status, _w_a_i_t_3 returns a _p_i_d of 0.  The WNOHANG and
     WUNTRACED options may be combined by _o_ring the 2 values.

NNNNOOOOTTTTEEEESSSS
     See _s_i_g_v_e_c(2) for a list of termination statuses (signals);
     0 status indicates normal termination.  A special status
     (WSTOPPED) is returned for a stopped process, which has not






     terminated and can be restarted.  If the w_coredump field of
     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.

     Both _w_a_i_t and _w_a_i_t_3 are automatically restarted when a pro-
     cess receives a signal while awaiting termination of a child
     process.

RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
     If _w_a_i_t returns due to a stopped or terminated child pro-
     cess, 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.

     _w_a_i_t_3 returns -1 if no children were previously awaited; 0
     is returned if WNOHANG is specified and there are no stopped
     or exited children.

EEEERRRRRRRROOOORRRRSSSS
     _w_a_i_t fails and returns immediately if one or more of the
     following is true:

     [ECHILD]       The calling process has no existing child
                    processes that are not already awaited.

     [EFAULT]       Either the _s_t_a_t_u_s or _r_u_s_a_g_e arguments point
                    to an illegal address.

SSSSEEEEEEEE AAAALLLLSSSSOOOO
     System Calls (2):  exit, sigvec

March 1989                              TX Programmer's Reference
























