HP-UX Reference (11i v2 04/09) - 2 System Calls (vol 5)
w
wait(2) wait(2)
If the information pointed to by stat_loc was stored by a call to
waitpid() that did not specify the WUN-
TRACED flag and specified the
WCONTINUED lag, or by a call to the wait() function, exactly one of the
macros
WIFEXITED(*stat_loc)
, WIFSIGNALED(*stat_loc)
, and
WIFCONTINUED(*stat_loc)
shall evaluate to a non-zero value.
There may be additional implementation-dependent circumstances under which
wait(), waitpid()
report status. 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 status 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.
In earlier versions of HP-UX, the status interpretation macros
WIFEXITED, WIFSIGNALED and WIFS-
TOPPED have the same definitions as the correspondingly named macros in BSD 4.3 and earlier systems,
so 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 so that the old definitions of
these macros override the new definitions of these macros that are in effect by default. The only
difference between the old and new definitions is the argument typing. Type union wait is used in the
BSD definitions while type int is used in the default definitions.
RETURN VALUE
If
wait() or waitpid() 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 status is reported.
If
wait() or waitpid() returns due to the delivery of a signal to the calling process, −1 shall be
returned and errno set to [EINTR].
If
waitpid() was invoked with WNOHANG set in options , it has at least one child process specified by
pid for which status is not available, and status is not available for any process specified by pid,0is
returned. Otherwise, (pid_t) −1 shall be returned, and errno set to indicate the error.
ERRORS
If the
wait() call fails, errno is set to one of the following values:
[ECHILD] The calling process has no existing unwaited-for child processes.
[EFAULT] The stat_loc argument points to an illegal address or problems were encountered in
the reporting of the status information for the specified child process. Note that the
reliable detection of this error is implementation-dependent.
[EINTR] The function was interrupted by a signal. The value of the location pointed to by
stat_loc argument is undefined.
If the
waitpid() call fails, errno is set to one of the following values:
[ECHILD] The process specified by pid does not exist or is not a child of the calling process, or
the process group specified by pid does not exist or does not have any member pro-
cess that is a child of the calling process.
[EFAULT] The stat_loc argument points to an illegal address or problems were encountered in
the reporting of the status information for the specified child process. Note that the
reliable detection of this error is implementation-dependent.
[EINTR] The waitpid() was interrupted by a signal. The value of the location pointed to
by stat_loc is undefined.
[EINVAL] The options argument is not valid.
WARNINGS
HP-UX EXTENSION: The operation of wait(), 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 res-
tarted can affect the EINTR condition (see bsdproc (3C), sigaction (2) and sigvector (2)).
APPLICATION USAGE
Threads Considerations
In a multi-threaded application, only the calling thread is suspended by
wait(), waitpid() call.
Section 2−−488 Hewlett-Packard Company − 3 − HP-UX 11i Version 2: September 2004