wait.2 (2010 09)

w
wait(2) wait(2)
HP-UX EXTENSION: If and only if this flag is set,
waitpid() or wait3() (see
wait3 (2)) returns information on child or attached processes that are stopped
because they received a
SIGTTIN, SIGTTOU,
SIGTSTP or SIGSTOP signal, and
whose status has not yet been reported. Regardless of this flag, status is returned
for child or attached processes that have terminated or are stopped and traced and
whose status has not yet been reported.
If the calling process has the signal action
SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, and
the process has no unwaited-for children that were transformed into zombie processes, the calling thread
blocks until all of the children of the process containing the calling thread terminate, and
wait() and
waitpid() fail and set errno to [ECHILD].
If
wait() or waitpid() return because the status of a child process is available, these functions
return a value equal to the process ID of the child process. In this case, if the value of the argument
stat_loc is not a null pointer, information is stored in the location pointed to by stat_loc . The value stored
at the location pointed to by stat_loc is 0 if and only if the status returned is from a terminated child pro-
cess that terminated by one of the following means:
1. The process returned 0 from main() .
2. The process called _exit() or exit() with a status argument of 0.
3. The process was terminated because the last thread in the process terminated.
Previous versions of HP-UX documented the bit encodings of the status returned by
wait() which could
be interpreted directly and applications doing this will continue to work correctly. However, new applica-
tions should use the provided status interpretation macros shown below for maximum portability.
Status Interpretation Macros
Regardless of its value, this information may be interpreted using the following macros, which are defined
in
<sys/wait.h> and evaluate to integral expressions; the stat_val argument is the integer value
pointed to by stat_loc .
WCOREDUMP(stat_val ) HP-UX EXTENSION: If the value of WIFSIGNALED(stat_val ) is
nonzero, this macro evaluates to a nonzero value if a "core image"
dump was produced (see signal (5)).
WEXITSTATUS(stat_val ) If the value of WIFEXITED(stat_val ) is nonzero, this macro evalu-
ates to the low-order 8 bits of the status argument that the child
process passed to _exit() or exit() or the value the child pro-
cess returned from main().
WIFCONTINUED(stat_val ) Evaluates to a nonzero value if status was returned for a child pro-
cess that has continued from a job control stop.
WIFEXITED(stat_val ) Evaluates to a nonzero value if status was reported for a child pro-
cess that terminated normally.
WIFSIGNALED(stat_val ) Evaluates to a nonzero value if status was reported for a child pro-
cess that terminated due to the receipt of a signal that was not
caught (see <signal.h>).
WIFSTOPPED(stat_val ) Evaluates to a nonzero value if status was reported for a child pro-
cess that is currently stopped.
WSTOPSIG(stat_val ) If the value of WIFSTOPPED(stat_val ) is nonzero, this macro
evaluates to the number of the signal that caused the child process
to stop.
WTERMSIG(stat_val ) If the value of WIFSIGNALED(stat_val ) is nonzero, this macro
evaluates to the number of the signal that caused the termination
of the child process.
If the information pointed to by stat_loc was stored by a call to
waitpid() that specified the WUN-
TRACED flag and did not specify the WCONTINUED flag, exactly one of the macros
WIFEXITED(*stat_loc ), WIFSIGNALED(*stat_loc ), and WIFSTOPPED(*stat_loc ) evaluates to a
nonzero value.
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010