HP-UX Reference (11i v2 04/09) - 2 System Calls (vol 5)

w
wait(2) wait(2)
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
shall block until all of the children of the process containing the calling thread terminate, and
wait()
and waitpid() shall fail and set errno to [ECHILD].
If
wait() or waitpid() 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
stat_loc is not a null pointer, information shall be stored in the location pointed to by stat_loc . The value
stored at the location pointed to by stat_loc shall be 0 if and only if the status returned is from a ter-
minated child process 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
non-zero, this macro evaluates to a non-zero value if a "core image"
dump was produced (see signal (5)).
WEXITSTATUS(stat_val)
If the value of WIFEXITED(stat_val) is non-zero, this macro
evaluates to the low-order 8 bits of the status argument that the child
process passed to
_exit() or exit() or the value the child process
returned from main().
WIFCONTINUED(stat_val)
Evaluates to a non-zero value if status was returned for a child process
that has continued from a job control stop.
WIFEXITED(stat_val)
Evaluates to a non-zero value if status was reported for a child process
that terminated normally.
WIFSIGNALED(stat_val)
Evaluates to a non-zero value if status was reported for a child process
that terminated due to the receipt of a signal that was not caught (see
<signal.h >).
WIFSTOPPED(stat_val)
Evaluates to a non-zero value if status was reported for a child process
that is currently stopped.
WSTOPSIG(stat_val) If the value of WIFSTOPPED(stat_val)
is non-zero, 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 non-zero, 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) shall
evaluate to a non-zero value.
If the information pointed to by stat_loc was stored by a call to
waitpid() that specified the WUN-
TRACED and WCONTINUED flags, exactly one of the macros WIFEXITED(*stat_loc),
WIFSIGNALED(*stat_loc), WIFSTOPPED(*stat_loc) and WIFCONTINUED(*stat_loc)
shall evaluate to a non-zero value.
If the information pointed to by stat_loc was stored by a call to
waitpid() that did not specify the WUN-
TRACED or WCONTINUED flags, or by a call to the wait() function, exactly one of the macros
WIFEXITED(*stat_loc) and WIFSIGNALED(*stat_loc) shall evaluate to a non-zero value.
HP-UX 11i Version 2: September 2004 2 Hewlett-Packard Company Section 2487