2.11BSD/man/cat2/wait3.0

Compare this file to the similar file:
Show the results in this format:




WAIT(2)             UNIX Programmer's Manual		  WAIT(2)



NAME
     wait, waitpid, wait4, wait3 - wait for process terminatation

SYNOPSIS
     #include <sys/types.h>
     #include <sys/wait.h>

     pid = wait(status)
     int pid;
     union wait *status;

     #include <sys/time.h>
     #include <sys/resource.h>

     pid = waitpid(wpid, status, options);
     int pid;
     int wpid;
     union wait *status;
     int options;

     pid = wait3(status, options, rusage);
     int pid;
     union wait *status;
     int options;
     struct rusage *rusage;

     pid = wait4(wpid, status, options, rusage);
     int pid;
     int wpid;
     union wait *status;
     int options;
     struct rusage *rusage;

DESCRIPTION
     The _w_a_i_t function suspends execution of its calling process
     until status information is available for a terminated child
     process, or a signal is received.	On return from a success-
     ful _w_a_i_t call, the status area contains termination informa-
     tion about the process that exited as defined below.

     The _w_a_i_t_4 call provides a more general interface for pro-
     grams that need to wait for certain child processes, that
     need resource utilization statistics accummulated by child
     processes, or that require options.  The other wait func-
     tions are implemented using _w_a_i_t_4 .

     The wpid parameter specifies the set of child processes for
     which to wait.  If wpid is -1, the call waits for any child
     process.  If wpid is 0, the call waits for any child process
     in the process group of the caller.  If wpid is greater than
     zero, the call waits for the process with process id wpid .
     If wpid is less than -1, the call waits for any process



Printed 11/26/99	 March 12, 1993                         1






WAIT(2)             UNIX Programmer's Manual		  WAIT(2)



     whose process group id equals the absolute value of wpid .

     The status parameter is defined below.  The options parame-
     ter contains the bitwise OR of any of the following options.
     The WNOHANG option is used to indicate that the call should
     not block if there are no processes that wish to report
     status.  If the WUNTRACED option is set, children of the
     current process that are stopped due to a SIGTTIN , SIGTTOU
     , SIGTSTP , or SIGSTOP signal also have their status
     reported.

     If rusage 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_4 returns a process id of 0.

     The _w_a_i_t_p_i_d call is identical to _w_a_i_t_4 with an rusage value
     of zero.  The older _w_a_i_t_3 call is the same as _w_a_i_t_4 with a
     wpid value of -1.

     The following macros may be used to test the manner of exit
     of the process.  One of the first three macros will evaluate
     to a non-zero (true) value:

     _W_I_F_E_X_I_T_E_D(_s_t_a_t_u_s) - True if the process terminated normally
     by a call to __e_x_i_t(_2) or _e_x_i_t(_2) .

     _W_I_F_S_I_G_N_A_L_E_D(_s_t_a_t_u_s) - True if the process terminated due to
     receipt of a signal.

     _W_I_F_S_T_O_P_P_E_D(_s_t_a_t_u_s) - True if the process has not terminated,
     but has stopped and can be restarted.  This macro can be
     true only if the wait call specified the WUNTRACED option or
     if the child process is being traced (see _p_t_r_a_c_e(_2)).

     Depending on the values of those macros, the following mac-
     ros produce the remaining status information about the child
     process:

     _W_E_X_I_T_S_T_A_T_U_S(_s_t_a_t_u_s) - If _W_I_F_E_X_I_T_E_D(_s_t_a_t_u_s) is true, evalu-
     ates to the low-order 8 bits of the argument passed to
     __e_x_i_t(_2) or _e_x_i_t(_2) by the child.

     _W_T_E_R_M_S_I_G(_s_t_a_t_u_s) - If _W_I_F_S_I_G_N_A_L_E_D(_s_t_a_t_u_s) is true, evaluates
     to the number of the signal that caused the termination of
     the process.

     _W_C_O_R_E_D_U_M_P(_s_t_a_t_u_s) If _W_I_F_S_I_G_N_A_L_E_D(_s_t_a_t_u_s) is true, evaluates
     as true if the termination of the process was accompanied by



Printed 11/26/99	 March 12, 1993                         2






WAIT(2)             UNIX Programmer's Manual		  WAIT(2)



     the creation of a core file containing an image of the pro-
     cess when the signal was received.

     _W_S_T_O_P_S_I_G(_s_t_a_t_u_s) If _W_I_F_S_T_O_P_P_E_D(_s_t_a_t_u_s) is true, evaluates to
     the number of the signal that caused the process to stop.

NOTES
     See _s_i_g_v_e_c(_2) for a list of termination signals.  A status
     of 0 indicates normal termination.

     If a parent process terminates without waiting for all of
     its child processes to terminate, the remaining child
     processes are assigned the parent process 1 ID (the init
     process ID).

     If a signal is caught while any of the _w_a_i_t calls is pend-
     ing, the call may be interrupted or restarted when the
     signal-catching routine returns, depending on the options in
     effect for the signal; see _i_n_t_r_o(_2), System call restart.

RETURN VALUES
     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.

     If _w_a_i_t_4(), _w_a_i_t_3() _o_r _w_a_i_t_p_i_d() returns due to a stopped or
     terminated child process, the process ID of the child is
     returned to the calling process.  If there are no children
     not previously awaited, -1 is returned with _e_r_r_n_o set to
     [ECHILD]. Otherwise, if WNOHANG is specified and there are
     no stopped or exited children, 0 is returned.  If an error
     is detected or a caught signal aborts the call, 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:

     [ECHILD]	    The calling process has no existing
		    unwaited-for child processes.

     [EFAULT]	    The _s_t_a_t_u_s or _r_u_s_a_g_e arguments point to an
		    illegal address.  (May not be detected before
		    exit of a child process.)

     [EINTR]	    The call was interrupted by a caught signal,
		    or the signal had the _S_V__I_N_T_E_R_R_U_P_T flag set.

STANDARDS
     The _w_a_i_t and _w_a_i_t_p_i_d functions are defined by POSIX; _w_a_i_t_4
     and _w_a_i_t_3 are not specified by POSIX.  The _W_C_O_R_E_D_U_M_P macro
     and the ability to restart a pending _w_a_i_t call are



Printed 11/26/99	 March 12, 1993                         3






WAIT(2)             UNIX Programmer's Manual		  WAIT(2)



     extensions to the POSIX interface.

SEE ALSO
     _e_x_i_t(_2) , _s_i_g_v_e_c(_2) A _w_a_i_t function call appeared in Version
     6 AT&T UNIX.


















































Printed 11/26/99	 March 12, 1993                         4