4.3BSD-Reno/share/man/cat2/wait4.0

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




WAIT(2)                       1989			  WAIT(2)



NNAAMMEE
     wait, waitpid, wait4, wait3 - wait for process to terminate

SSYYNNOOPPSSIISS
     ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
     ##iinncclluuddee <<ssyyss//wwaaiitt..hh>>

     ppiidd == wwaaiitt((ssttaattuuss))
     ppiidd__tt ppiidd;;
     iinntt **ssttaattuuss;;

     ppiidd == wwaaiittppiidd((wwppiidd,, ssttaattuuss,, ooppttiioonnss))
     ppiidd__tt ppiidd,, wwppiidd;;
     iinntt **ssttaattuuss;;
     iinntt ooppttiioonnss;;

     ##iinncclluuddee <<ssyyss//ttiimmee..hh>>
     ##iinncclluuddee <<ssyyss//rreessoouurrccee..hh>>

     ppiidd == wwaaiitt44((wwppiidd,, ssttaattuuss,, ooppttiioonnss,, rruussaaggee))
     ppiidd__tt ppiidd,, wwppiidd;;
     iinntt **ssttaattuuss;;
     iinntt ooppttiioonnss;;
     ssttrruucctt rruussaaggee **rruussaaggee;;

     ppiidd == wwaaiitt33((ssttaattuuss,, ooppttiioonnss,, rruussaaggee))
     ppiidd__tt ppiidd;;
     iinntt **ssttaattuuss;;
     iinntt ooppttiioonnss;;
     ssttrruucctt rruussaaggee **rruussaaggee;;

DDEESSCCRRIIPPTTIIOONN
     _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, returning the
     process id and exit status of one of the terminated chil-
     dren.  If there are no children, return is immediate with
     the value -1 returned.

     On return from a successful _w_a_i_t call, the _s_t_a_t_u_s area con-
     tains termination information about the process that exited
     as defined below.

     The _w_a_i_t_4 call provides a more general interface for pro-
     grams that wish to wait for certain child processes, that
     wish 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 _w_p_i_d parameter specifies the set of child processes for
     which to wait.  If _w_p_i_d is -1, the call waits for any child
     process.  If _w_p_i_d is 0, the call waits for any child process



Printed 7/27/90              August				1






WAIT(2)                       1989			  WAIT(2)



     in the process group of the caller.  If _w_p_i_d is greater than
     zero, the call waits for the process with process id _w_p_i_d.
     If _w_p_i_d is less than -1, the call waits for any process
     whose process group id equals the absolute value of _w_p_i_d.

     The _s_t_a_t_u_s parameter is defined below.  The _o_p_t_i_o_n_s 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 _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_4 returns a _p_i_d of 0.

     The _w_a_i_t_p_i_d call is identical to _w_a_i_t_4 with an _r_u_s_a_g_e value
     of zero.  The older _w_a_i_t_3 call is the same as _w_a_i_t_4 with a
     _w_p_i_d 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:

     WIFEXITED(status)
	  True if the process terminated normally by a call to
	  __e_x_i_t(2) or _e_x_i_t(2).

     WIFSIGNALED(status)
	  True if the process terminated due to receipt of a sig-
	  nal.

     WIFSTOPPED(status)
	  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:

     WEXITSTATUS(status)
	  If WIFEXITED(status) is true, evaluates 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.




Printed 7/27/90              August				2






WAIT(2)                       1989			  WAIT(2)



     WTERMSIG(status)
	  If WIFSIGNALED(status) is true, evaluates to the number
	  of the signal that caused the termination of the pro-
	  cess.

     WCOREDUMP(status)
	  If WIFSIGNALED(status) is true, evaluates as true if
	  the termination of the process was accompanied by the
	  creation of a core file containing an image of the pro-
	  cess when the signal was received.

     WSTOPSIG(status)
	  If WIFSTOPPED(status) is true, evaluates to the number
	  of the signal that caused the process to stop.

NNOOTTEESS
     See _s_i_g_a_c_t_i_o_n(2) for a list of termination signals.  A
     status of 0 indicates normal termination.

     If the parent process terminates without waiting on its
     children, the initialization process (process ID = 1) inher-
     its the children.

     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.

RREETTUURRNN VVAALLUUEE
     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 or _w_a_i_t_p_i_d returns due to a stopped or ter-
     minated 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.

EERRRROORRSS
     _W_a_i_t will fail and return immediately if one or more of the
     following are true:

     [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



Printed 7/27/90              August				3






WAIT(2)                       1989			  WAIT(2)



		    exit of a child process.)

     [EINTR]	    The call was interrupted by a caught signal,
		    or the signal did not have the SA_RESTART
		    flag set.

SSTTAANNDDAARRDDSS
     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 WCOREDUMP macro
     and the ability to restart a pending _w_a_i_t call are exten-
     sions to the POSIX interface.

SSEEEE AALLSSOO
     exit(2), sigaction(2)









































Printed 7/27/90              August				4