WAIT(3)                    POSIX Programmer's Manual                   WAIT(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.

NNAAMMEE
       wait, waitpid -- wait for a child process to stop or terminate

SSYYNNOOPPSSIISS
       #include <sys/wait.h>

       pid_t wait(int *_s_t_a_t___l_o_c);
       pid_t waitpid(pid_t _p_i_d, int *_s_t_a_t___l_o_c, int _o_p_t_i_o_n_s);

DDEESSCCRRIIPPTTIIOONN
       The _w_a_i_t() and _w_a_i_t_p_i_d() functions shall obtain status information (see
       _S_e_c_t_i_o_n _2_._1_3, _S_t_a_t_u_s _I_n_f_o_r_m_a_t_i_o_n) pertaining to one of the caller's
       child processes. The _w_a_i_t() function obtains status information for
       process termination from any child process. The _w_a_i_t_p_i_d() function
       obtains status information for process termination, and optionally
       process stop and/or continue, from a specified subset of the child
       processes.

       The _w_a_i_t() function shall cause the calling thread to become blocked
       until status information generated by child process termination is made
       available to the thread, or until delivery of a signal whose action is
       either to execute a signal-catching function or to terminate the
       process, or an error occurs. If termination status information is
       available prior to the call to _w_a_i_t(), return shall be immediate. If
       termination status information is available for two or more child
       processes, the order in which their status is reported is unspecified.

       As described in _S_e_c_t_i_o_n _2_._1_3, _S_t_a_t_u_s _I_n_f_o_r_m_a_t_i_o_n, the _w_a_i_t() and
       _w_a_i_t_p_i_d() functions consume the status information they obtain.

       The behavior when multiple threads are blocked in _w_a_i_t(), _w_a_i_t_i_d(), or
       _w_a_i_t_p_i_d() is described in _S_e_c_t_i_o_n _2_._1_3, _S_t_a_t_u_s _I_n_f_o_r_m_a_t_i_o_n.

       The _w_a_i_t_p_i_d() function shall be equivalent to _w_a_i_t() if the _p_i_d
       argument is (ppiidd__tt)-1 and the _o_p_t_i_o_n_s argument is 0. Otherwise, its
       behavior shall be modified by the values of the _p_i_d and _o_p_t_i_o_n_s
       arguments.

       The _p_i_d argument specifies a set of child processes for which _s_t_a_t_u_s is
       requested. The _w_a_i_t_p_i_d() function shall only return the status of a
       child process from this set:

        *  If _p_i_d is equal to (ppiidd__tt)-1, _s_t_a_t_u_s is requested for any child
           process. In this respect, _w_a_i_t_p_i_d() is then equivalent to _w_a_i_t().

        *  If _p_i_d is greater than 0, it specifies the process ID of a single
           child process for which _s_t_a_t_u_s is requested.

        *  If _p_i_d is 0, _s_t_a_t_u_s is requested for any child process whose
           process group ID is equal to that of the calling process.

        *  If _p_i_d is less than (ppiidd__tt)-1, _s_t_a_t_u_s is requested for any child
           process whose process group ID is equal to the absolute value of
           _p_i_d.

       The _o_p_t_i_o_n_s argument is constructed from the bitwise-inclusive OR of
       zero or more of the following flags, defined in the _<_s_y_s_/_w_a_i_t_._h_>
       header:

       WCONTINUED  The _w_a_i_t_p_i_d() function shall report the status of any
                   continued child process specified by _p_i_d whose status has
                   not been reported since it continued from a job control
                   stop.

       WNOHANG     The _w_a_i_t_p_i_d() function shall not suspend execution of the
                   calling thread if _s_t_a_t_u_s is not immediately available for
                   one of the child processes specified by _p_i_d.

       WUNTRACED   The status of any child processes specified by _p_i_d that are
                   stopped, and whose status has not yet been reported since
                   they stopped, shall also be reported to the requesting
                   process.

       If _w_a_i_t() or _w_a_i_t_p_i_d() return because the status of a child process is
       available, these functions shall return a value equal to the process ID
       of the child process. In this case, if the value of the argument
       _s_t_a_t___l_o_c is not a null pointer, information shall be stored in the
       location pointed to by _s_t_a_t___l_o_c.  The value stored at the location
       pointed to by _s_t_a_t___l_o_c shall be 0 if and only if the status returned is
       from a terminated child process that terminated by one of the following
       means:

        1. The process returned 0 from _m_a_i_n().

        2. The process called ___e_x_i_t() or _e_x_i_t() with a _s_t_a_t_u_s argument of 0.

        3. The process was terminated because the last thread in the process
           terminated.

       Regardless of its value, this information may be interpreted using the
       following macros, which are defined in _<_s_y_s_/_w_a_i_t_._h_> and evaluate to
       integral expressions; the _s_t_a_t___v_a_l argument is the integer value
       pointed to by _s_t_a_t___l_o_c.

       WIFEXITED(_s_t_a_t___v_a_l)
             Evaluates to a non-zero value if _s_t_a_t_u_s was returned for a child
             process that terminated normally.

       WEXITSTATUS(_s_t_a_t___v_a_l)
             If the value of WIFEXITED(_s_t_a_t___v_a_l) is non-zero, this macro
             evaluates to the low-order 8 bits of the _s_t_a_t_u_s argument that the
             child process passed to ___e_x_i_t() or _e_x_i_t(), or the value the child
             process returned from _m_a_i_n().

       WIFSIGNALED(_s_t_a_t___v_a_l)
             Evaluates to a non-zero value if _s_t_a_t_u_s was returned for a child
             process that terminated due to the receipt of a signal that was
             not caught (see _<_s_i_g_n_a_l_._h_>).

       WTERMSIG(_s_t_a_t___v_a_l)
             If the value of WIFSIGNALED(_s_t_a_t___v_a_l) is non-zero, this macro
             evaluates to the number of the signal that caused the termination
             of the child process.

       WIFSTOPPED(_s_t_a_t___v_a_l)
             Evaluates to a non-zero value if _s_t_a_t_u_s was returned for a child
             process that is currently stopped.

       WSTOPSIG(_s_t_a_t___v_a_l)
             If the value of WIFSTOPPED(_s_t_a_t___v_a_l) is non-zero, this macro
             evaluates to the number of the signal that caused the child
             process to stop.

       WIFCONTINUED(_s_t_a_t___v_a_l)
             Evaluates to a non-zero value if _s_t_a_t_u_s was returned for a child
             process that has continued from a job control stop.

       It is unspecified whether the _s_t_a_t_u_s value returned by calls to _w_a_i_t()
       or _w_a_i_t_p_i_d() for processes created by _p_o_s_i_x___s_p_a_w_n() or _p_o_s_i_x___s_p_a_w_n_p()
       can indicate a WIFSTOPPED(_s_t_a_t___v_a_l) before subsequent calls to _w_a_i_t()
       or _w_a_i_t_p_i_d() indicate WIFEXITED(_s_t_a_t___v_a_l) as the result of an error
       detected before the new process image starts executing.

       It is unspecified whether the _s_t_a_t_u_s value returned by calls to _w_a_i_t()
       or _w_a_i_t_p_i_d() for processes created by _p_o_s_i_x___s_p_a_w_n() or _p_o_s_i_x___s_p_a_w_n_p()
       can indicate a WIFSIGNALED(_s_t_a_t___v_a_l) if a signal is sent to the
       parent's process group after _p_o_s_i_x___s_p_a_w_n() or _p_o_s_i_x___s_p_a_w_n_p() is called.

       If the information pointed to by _s_t_a_t___l_o_c was stored by a call to
       _w_a_i_t_p_i_d() that specified the WUNTRACED flag and did not specify the
       WCONTINUED flag, exactly one of the macros WIFEXITED(*_s_t_a_t___l_o_c),
       WIFSIGNALED(*_s_t_a_t___l_o_c), and WIFSTOPPED(*_s_t_a_t___l_o_c) shall evaluate to a
       non-zero value.

       If the information pointed to by _s_t_a_t___l_o_c was stored by a call to
       _w_a_i_t_p_i_d() that specified the WUNTRACED and WCONTINUED flags, exactly
       one of the macros WIFEXITED(*_s_t_a_t___l_o_c), WIFSIGNALED(*_s_t_a_t___l_o_c),
       WIFSTOPPED(*_s_t_a_t___l_o_c), and WIFCONTINUED(*_s_t_a_t___l_o_c) shall evaluate to a
       non-zero value.

       If the information pointed to by _s_t_a_t___l_o_c was stored by a call to
       _w_a_i_t_p_i_d() that did not specify the WUNTRACED or WCONTINUED flags, or by
       a call to the _w_a_i_t() function, exactly one of the macros
       WIFEXITED(*_s_t_a_t___l_o_c) and WIFSIGNALED(*_s_t_a_t___l_o_c) shall evaluate to a
       non-zero value.

       If the information pointed to by _s_t_a_t___l_o_c was stored by a call to
       _w_a_i_t_p_i_d() that did not specify the WUNTRACED flag and specified the
       WCONTINUED flag, exactly one of the macros WIFEXITED(*_s_t_a_t___l_o_c),
       WIFSIGNALED(*_s_t_a_t___l_o_c), and WIFCONTINUED(*_s_t_a_t___l_o_c) shall evaluate to a
       non-zero value.

       If _POSIX_REALTIME_SIGNALS is defined, and the implementation queues
       the SIGCHLD signal, then if _w_a_i_t() or _w_a_i_t_p_i_d() returns because the
       status of a child process is available, any pending SIGCHLD signal
       associated with the process ID of the child process shall be discarded.
       Any other pending SIGCHLD signals shall remain pending.

       Otherwise, if SIGCHLD is blocked, if _w_a_i_t() or _w_a_i_t_p_i_d() return because
       the status of a child process is available, any pending SIGCHLD signal
       shall be cleared unless the status of another child process is
       available.

       For all other conditions, it is unspecified whether child _s_t_a_t_u_s will
       be available when a SIGCHLD signal is delivered.

       There may be additional implementation-defined circumstances under
       which _w_a_i_t() or _w_a_i_t_p_i_d() report _s_t_a_t_u_s.  This shall not occur unless
       the calling process or one of its child processes explicitly makes use
       of a non-standard extension. In these cases the interpretation of the
       reported _s_t_a_t_u_s is implementation-defined.

       If a parent process terminates without waiting for all of its child
       processes to terminate, the remaining child processes shall be assigned
       a new parent process ID corresponding to an implementation-defined
       system process.

RREETTUURRNN VVAALLUUEE
       If _w_a_i_t() or _w_a_i_t_p_i_d() returns because the status of a child process is
       available, these functions shall return a value equal to the process ID
       of the child process for which _s_t_a_t_u_s is reported. If _w_a_i_t() or
       _w_a_i_t_p_i_d() returns due to the delivery of a signal to the calling
       process, -1 shall be returned and _e_r_r_n_o set to [[EEIINNTTRR]].  If _w_a_i_t_p_i_d()
       was invoked with WNOHANG set in _o_p_t_i_o_n_s, it has at least one child
       process specified by _p_i_d for which _s_t_a_t_u_s is not available, and _s_t_a_t_u_s
       is not available for any process specified by _p_i_d, 0 is returned.
       Otherwise, -1 shall be returned, and _e_r_r_n_o set to indicate the error.

EERRRROORRSS
       The _w_a_i_t() function shall fail if:

       EECCHHIILLDD The calling process has no existing unwaited-for child
              processes.

       EEIINNTTRR  The function was interrupted by a signal. The value of the
              location pointed to by _s_t_a_t___l_o_c is undefined.

       The _w_a_i_t_p_i_d() function shall fail if:

       EECCHHIILLDD The process specified by _p_i_d does not exist or is not a child of
              the calling process, or the process group specified by _p_i_d does
              not exist or does not have any member process that is a child of
              the calling process.

       EEIINNTTRR  The function was interrupted by a signal. The value of the
              location pointed to by _s_t_a_t___l_o_c is undefined.

       EEIINNVVAALL The _o_p_t_i_o_n_s argument is not valid.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
   WWaaiittiinngg ffoorr aa CChhiilldd PPrroocceessss aanndd tthheenn CChheecckkiinngg iittss SSttaattuuss
       The following example demonstrates the use of _w_a_i_t_p_i_d(), _f_o_r_k(), and
       the macros used to interpret the status value returned by _w_a_i_t_p_i_d()
       (and _w_a_i_t()).  The code segment creates a child process which does some
       unspecified work. Meanwhile the parent loops performing calls to
       _w_a_i_t_p_i_d() to monitor the status of the child. The loop terminates when
       child termination is detected.


           #include <stdio.h>
           #include <stdlib.h>
           #include <unistd.h>
           #include <sys/wait.h>
           ...

           pid_t child_pid, wpid;
           int status;

           child_pid = fork();
           if (child_pid == -1) {      /* fork() failed */
               perror("fork");
               exit(EXIT_FAILURE);
           }

           if (child_pid == 0) {       /* This is the child */
               /* Child does some work and then terminates */
               ...

           } else {                    /* This is the parent */
               do {
                   wpid = waitpid(child_pid, &status, WUNTRACED
           #ifdef WCONTINUED       /* Not all implementations support this */
                   | WCONTINUED
           #endif
                   );
                   if (wpid == -1) {
                       perror("waitpid");
                       exit(EXIT_FAILURE);
                   }

                   if (WIFEXITED(status)) {
                       printf("child exited, status=%d\n", WEXITSTATUS(status));

                   } else if (WIFSIGNALED(status)) {
                       printf("child killed (signal %d)\n", WTERMSIG(status));

                   } else if (WIFSTOPPED(status)) {
                       printf("child stopped (signal %d)\n", WSTOPSIG(status));

           #ifdef WIFCONTINUED     /* Not all implementations support this */
                   } else if (WIFCONTINUED(status)) {
                       printf("child continued\n");
           #endif
                   } else {    /* Non-standard case -- may never happen */
                       printf("Unexpected status (0x%x)\n", status);
                   }
               } while (!WIFEXITED(status) && !WIFSIGNALED(status));
           }

   WWaaiittiinngg ffoorr aa CChhiilldd PPrroocceessss iinn aa SSiiggnnaall HHaannddlleerr ffoorr SSIIGGCCHHLLDD
       The following example demonstrates how to use _w_a_i_t_p_i_d() in a signal
       handler for SIGCHLD without passing -1 as the _p_i_d argument. (See the
       APPLICATION USAGE section below for the reasons why passing a _p_i_d of -1
       is not recommended.) The method used here relies on the standard
       behavior of _w_a_i_t_p_i_d() when SIGCHLD is blocked. On historical non-
       conforming systems, the status of some child processes might not be
       reported.


           #include <stdlib.h>
           #include <stdio.h>
           #include <signal.h>
           #include <sys/types.h>
           #include <sys/wait.h>
           #include <unistd.h>

           #define CHILDREN 10

           static void
           handle_sigchld(int signum, siginfo_t *sinfo, void *unused)
           {
               int sav_errno = errno;
               int status;

               /*
                * Obtain status information for the child which
                * caused the SIGCHLD signal and write its exit code
                * to stdout.
               */
               if (sinfo->si_code != CLD_EXITED)
               {
                   static char msg[] = "wrong si_code\n";
                   write(2, msg, sizeof msg - 1);
               }
               else if (waitpid(sinfo->si_pid, &status, 0) == -1)
               {
                   static char msg[] = "waitpid() failed\n";
                   write(2, msg, sizeof msg - 1);
               }
               else if (!WIFEXITED(status))
               {
                   static char msg[] = "WIFEXITED was false\n";
                   write(2, msg, sizeof msg - 1);
               }
               else
               {
                   int code = WEXITSTATUS(status);
                   char buf[2];
                   buf[0] = '0' + code;
                   buf[1] = '\n';
                   write(1, buf, 2);
               }
               errno = sav_errno;
           }

           int
           main(void)
           {
               int i;
               pid_t pid;
               struct sigaction sa;

               sa.sa_flags = SA_SIGINFO;
               sa.sa_sigaction = handle_sigchld;
               sigemptyset(&sa.sa_mask);
               if (sigaction(SIGCHLD, &sa, NULL) == -1)
               {
                   perror("sigaction");
                   exit(EXIT_FAILURE);
               }

               for (i = 0; i < CHILDREN; i++)
               {
                   switch (pid = fork())
                   {
                   case -1:
                       perror("fork");
                       exit(EXIT_FAILURE);
                   case 0:
                       sleep(2);
                       _exit(i);
                   }
               }

               /* Wait for all the SIGCHLD signals, then terminate on SIGALRM */
               alarm(3);
               for (;;)
                   pause();

               return 0; /* NOTREACHED */
           }

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       Calls to _w_a_i_t() will collect information about any child process. This
       may result in interactions with other interfaces that may be waiting
       for their own children (such as by use of _s_y_s_t_e_m()).  For this and
       other reasons it is recommended that portable applications not use
       _w_a_i_t(), but instead use _w_a_i_t_p_i_d().  For these same reasons, the use of
       _w_a_i_t_p_i_d() with a _p_i_d argument of -1, and the use of _w_a_i_t_i_d() with the
       _i_d_t_y_p_e argument set to P_ALL, are also not recommended for portable
       applications.

       As specified in _C_o_n_s_e_q_u_e_n_c_e_s _o_f _P_r_o_c_e_s_s _T_e_r_m_i_n_a_t_i_o_n, if the calling
       process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, then the
       termination of a child process will not cause status information to
       become available to a thread blocked in _w_a_i_t(), _w_a_i_t_i_d(), or _w_a_i_t_p_i_d().
       Thus, a thread blocked in one of the wait functions will remain blocked
       unless some other condition causes the thread to resume execution (such
       as an [[EECCHHIILLDD]] failure due to no remaining children in the set of
       waited-for children).

RRAATTIIOONNAALLEE
       A call to the _w_a_i_t() or _w_a_i_t_p_i_d() function only returns _s_t_a_t_u_s on an
       immediate child process of the calling process; that is, a child that
       was produced by a single _f_o_r_k() call (perhaps followed by an _e_x_e_c or
       other function calls) from the parent. If a child produces
       grandchildren by further use of _f_o_r_k(), none of those grandchildren nor
       any of their descendants affect the behavior of a _w_a_i_t() from the
       original parent process. Nothing in this volume of POSIX.1-2017
       prevents an implementation from providing extensions that permit a
       process to get _s_t_a_t_u_s from a grandchild or any other process, but a
       process that does not use such extensions must be guaranteed to see
       _s_t_a_t_u_s from only its direct children.

       The _w_a_i_t_p_i_d() function is provided for three reasons:

        1. To support job control

        2. To permit a non-blocking version of the _w_a_i_t() function

        3. To permit a library routine, such as _s_y_s_t_e_m() or _p_c_l_o_s_e(), to wait
           for its children without interfering with other terminated children
           for which the process has not waited

       The first two of these facilities are based on the _w_a_i_t_3() function
       provided by 4.3 BSD. The function uses the _o_p_t_i_o_n_s argument, which is
       equivalent to an argument to _w_a_i_t_3().  The WUNTRACED flag is used only
       in conjunction with job control on systems supporting job control. Its
       name comes from 4.3 BSD and refers to the fact that there are two types
       of stopped processes in that implementation: processes being traced via
       the _p_t_r_a_c_e() debugging facility and (untraced) processes stopped by job
       control signals. Since _p_t_r_a_c_e() is not part of this volume of
       POSIX.1-2017, only the second type is relevant. The name WUNTRACED was
       retained because its usage is the same, even though the name is not
       intuitively meaningful in this context.

       The third reason for the _w_a_i_t_p_i_d() function is to permit independent
       sections of a process to spawn and wait for children without
       interfering with each other. For example, the following problem occurs
       in developing a portable shell, or command interpreter:


           stream = popen("/bin/true");
           (void) system("sleep 100");
           (void) pclose(stream);

       On all historical implementations, the final _p_c_l_o_s_e() fails to reap the
       _w_a_i_t() _s_t_a_t_u_s of the _p_o_p_e_n().

       The status values are retrieved by macros, rather than given as
       specific bit encodings as they are in most historical implementations
       (and thus expected by existing programs). This was necessary to
       eliminate a limitation on the number of signals an implementation can
       support that was inherent in the traditional encodings. This volume of
       POSIX.1-2017 does require that a _s_t_a_t_u_s value of zero corresponds to a
       process calling ___e_x_i_t(0), as this is the most common encoding expected
       by existing programs.  Some of the macro names were adopted from 4.3
       BSD.

       These macros syntactically operate on an arbitrary integer value. The
       behavior is undefined unless that value is one stored by a successful
       call to _w_a_i_t() or _w_a_i_t_p_i_d() in the location pointed to by the _s_t_a_t___l_o_c
       argument. An early proposal attempted to make this clearer by
       specifying each argument as *_s_t_a_t___l_o_c rather than _s_t_a_t___v_a_l.  However,
       that did not follow the conventions of other specifications in this
       volume of POSIX.1-2017 or traditional usage. It also could have implied
       that the argument to the macro must literally be *_s_t_a_t___l_o_c; in fact,
       that value can be stored or passed as an argument to other functions
       before being interpreted by these macros.

       The extension that affects _w_a_i_t() and _w_a_i_t_p_i_d() and is common in
       historical implementations is the _p_t_r_a_c_e() function. It is called by a
       child process and causes that child to stop and return a _s_t_a_t_u_s that
       appears identical to the _s_t_a_t_u_s indicated by WIFSTOPPED.  The _s_t_a_t_u_s of
       _p_t_r_a_c_e() children is traditionally returned regardless of the WUNTRACED
       flag (or by the _w_a_i_t() function). Most applications do not need to
       concern themselves with such extensions because they have control over
       what extensions they or their children use. However, applications, such
       as command interpreters, that invoke arbitrary processes may see this
       behavior when those arbitrary processes misuse such extensions.

       Implementations that support ccoorree file creation or other
       implementation-defined actions on termination of some processes
       traditionally provide a bit in the _s_t_a_t_u_s returned by _w_a_i_t() to
       indicate that such actions have occurred.

       Allowing the _w_a_i_t() family of functions to discard a pending SIGCHLD
       signal that is associated with a successfully waited-for child process
       puts them into the _s_i_g_w_a_i_t() and _s_i_g_w_a_i_t_i_n_f_o() category with respect to
       SIGCHLD.

       This definition allows implementations to treat a pending SIGCHLD
       signal as accepted by the process in _w_a_i_t(), with the same meaning of
       ``accepted'' as when that word is applied to the _s_i_g_w_a_i_t() family of
       functions.

       Allowing the _w_a_i_t() family of functions to behave this way permits an
       implementation to be able to deal precisely with SIGCHLD signals.

       In particular, an implementation that does accept (discard) the SIGCHLD
       signal can make the following guarantees regardless of the queuing
       depth of signals in general (the list of waitable children can hold the
       SIGCHLD queue):

        1. If a SIGCHLD signal handler is established via _s_i_g_a_c_t_i_o_n() without
           the SA_RESETHAND flag, SIGCHLD signals can be accurately counted;
           that is, exactly one SIGCHLD signal will be delivered to or
           accepted by the process for every child process that terminates.

        2. A single _w_a_i_t() issued from a SIGCHLD signal handler can be
           guaranteed to return immediately with status information for a
           child process.

        3. When SA_SIGINFO is requested, the SIGCHLD signal handler can be
           guaranteed to receive a non-null pointer to a ssiiggiinnffoo__tt structure
           that describes a child process for which a wait via _w_a_i_t_p_i_d() or
           _w_a_i_t_i_d() will not block or fail.

        4. The _s_y_s_t_e_m() function will not cause the SIGCHLD handler of a
           process to be called as a result of the _f_o_r_k()/_e_x_e_c executed within
           _s_y_s_t_e_m() because _s_y_s_t_e_m() will accept the SIGCHLD signal when it
           performs a _w_a_i_t_p_i_d() for its child process. This is a desirable
           behavior of _s_y_s_t_e_m() so that it can be used in a library without
           causing side-effects to the application linked with the library.

       An implementation that does not permit the _w_a_i_t() family of functions
       to accept (discard) a pending SIGCHLD signal associated with a
       successfully waited-for child, cannot make the guarantees described
       above for the following reasons:

       Guarantee #1
             Although it might be assumed that reliable queuing of all SIGCHLD
             signals generated by the system can make this guarantee, the
             counter-example is the case of a process that blocks SIGCHLD and
             performs an indefinite loop of _f_o_r_k()/_w_a_i_t() operations. If the
             implementation supports queued signals, then eventually the
             system will run out of memory for the queue. The guarantee cannot
             be made because there must be some limit to the depth of queuing.

       Guarantees #2 and #3
             These cannot be guaranteed unless the _w_a_i_t() family of functions
             accepts the SIGCHLD signal. Otherwise, a _f_o_r_k()/_w_a_i_t() executed
             while SIGCHLD is blocked (as in the _s_y_s_t_e_m() function) will
             result in an invocation of the handler when SIGCHLD is unblocked,
             after the process has disappeared.

       Guarantee #4
             Although possible to make this guarantee, _s_y_s_t_e_m() would have to
             set the SIGCHLD handler to SIG_DFL so that the SIGCHLD signal
             generated by its _f_o_r_k() would be discarded (the SIGCHLD default
             action is to be ignored), then restore it to its previous
             setting. This would have the undesirable side-effect of
             discarding all SIGCHLD signals pending to the process.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _S_e_c_t_i_o_n _2_._1_3, _S_t_a_t_u_s _I_n_f_o_r_m_a_t_i_o_n, _e_x_e_c, _e_x_i_t(), _f_o_r_k(), _s_y_s_t_e_m(),
       _w_a_i_t_i_d()

       The Base Definitions volume of POSIX.1-2017, _S_e_c_t_i_o_n _4_._1_2, _M_e_m_o_r_y
       _S_y_n_c_h_r_o_n_i_z_a_t_i_o_n, <<ssiiggnnaall..hh>>, <<ssyyss__wwaaiitt..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version and the
       original IEEE and The Open Group Standard, the original IEEE and The
       Open Group Standard is the referee document. The original Standard can
       be obtained online at http://www.opengroup.org/unix/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                              WAIT(3)
