wait3() — Wait for child process to change state
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 | both |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/wait.h>
pid_t wait3(int *stat_loc, int options, struct rusage *resource_usage);
General description
The wait3() function allows the calling process to obtain status information for specified child processes.
wait3(stat_loc, options, resource_usage)
is
equivalent to the call:
waitpid((pid_t)-1, stat_loc, options);
except that on successful completion, if the resource_usage argument to wait3() is not a NULL pointer, the rusage structure that the third argument points to is filled in for the child process identified by the return value.
This function is kept for historical reasons. It was part of the Legacy Feature in Single UNIX Specification, Version 2, but has been withdrawn and is not supported as part of Single UNIX Specification, Version 3. The waitpid() function is preferred for portability.
If it is necessary to continue using this function in an application written for Single UNIX Specification, Version 3, define the feature test macro _UNIX03_WITHDRAWN before including any standard system headers. The macro exposes all interfaces and symbols removed in Single UNIX Specification, Version 3.
Returned value
See waitpid() — Wait for a specific child process to end.
- Error Code
- Description
- ECHILD
- The calling process has no existing unwaited-for child processes, or if the set of processes specified by the argument pid can never be in the states specified by the argument options.