HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)
w
wait(2) wait(2)
HP-UX EXTENSIONS
NAME
wait(), waitpid() - wait for child or traced process to stop or terminate
DESCRIPTION
wait()
If a parent process terminates without waiting for its child processes to terminate, the parent process ID of
each child process is set to 1. This means the initialization process inherits the child processes.
WCOREDUMP(*stat_loc)
If the value of WIFSIGNALED(*stat_loc)
is nonzero, this macro evaluates to a
nonzero value if a "core image" was produced (see signal(5)).
waitpid()
WNOWAIT Keep the process whose status is returned in *stat_loc in a waitable state. The process
may be waited for again with identical results, provided the state of the process
doesn’t change in the interim.
WUNTRACED If and only if this flag is set, waitpid() or wait3() returns information on child
or attached processes that are stopped but not traced (with ptrace()) because they
received a SIGTTIN, SIGTTOU, SIGTSTP,orSIGSTOP 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.
Notes
Earlier HP-UX versions documented the bit encodings of the status returned by wait() rather than the
macros
WCOREDUMP, WEXITSTATUS , WIFEXITED , WIFSIGNALED , WIFSTOPPED, WSTOPSIG, and
WTERMSIG. Applications using those bit encodings will continue to work correctly. However, new applica-
tions should use the macros for maximum portability.
In earlier HP-UX versions, the macros WIFEXITED , WIFSIGNALED , and WIFSTOPPED have the same
definitions as the correspondingly named macros in the BSD 4.3 and earlier systems. Existing applications
that depend on these definitions will continue to work correctly. However, if the application is recompiled,
the feature test macro _BSD must be turned on for the compilation so that the old definitions of these mac-
ros are obtained.
New definitions of these macros are in effect by default. The only difference between the old and new
definitions is the type of the argument. Type union wait is used in the BSD definitions while type int is
used in the default definitions.
ERRORS
If
wait() or waitpid() fails, errno is set to one of the following values.
[EACCES] The calling process of waitpid() does not have read permission to the pid.
[EFAULT] stat_loc points to an illegal address. The reliable detection of this error is
implementation-dependent.
WARNINGS
The behavior of
wait() and waitpid() is affected if the SIGCLD signal is set to SIG_IGN. See the
WARNINGS section of signal(5). Signal handlers that cause system calls to be restarted can affect the
[EINTR] condition described above (see bsdproc(3C), sigaction(2), and sigvector(2)).
AUTHOR
wait(), waitpid(), and wait3() were developed by HP, AT&T, and the University of California, Berkeley.
SEE ALSO
Exit conditions ($?) in sh(1); exec(2), exit(2), fork(2), pause(2), ptrace(2), signal(5).
Section 2−−474 Hewlett-Packard Company − 1 − HP-UX 11i Version 1: September 2005