#include <sys/types.h>
|
#include <sys/wait.h>
|
pid_t
wait (int *status); |
#include <sys/time.h>
|
#include <sys/resource.h>
|
pid_t
waitpid (pid_t wpid, int *status, int options); |
If wait4, wait3, or waitpid returns due to a stopped or terminated child process, the process ID of the child is returned to the calling process. If there are no children not previously awaited, -1 is returned with errno set to ECHILD. Otherwise, if WNOHANG is specified and there are no stopped or exited children, 0 is returned. If an error is detected or a caught signal aborts the call, a value of -1 is returned and errno is set to indicate the error.
The wpid argument specifies the set of child processes for which to wait. If wpid is -1, the call waits for any child process. If wpid is 0, the call waits for any child process in the process group of the caller. If wpid is greater than zero, the call waits for the process with process id wpid. If wpid is less than -1, the call waits for any process whose process group id equals the absolute value of wpid.
The waitpid function is identical to wait4 with an rusage value of zero.
Limitation: The waitpid waits on a pid which obtained using an non-standard api popen3
[ECHILD] | |
The calling process has no existing unwaited-for child processes. | |
[ECHILD] | |
No status from the terminated child process is available because the calling process has asked the system to discard such status by ignoring the signal SIGCHLD or setting the flag SA_NOCLDWAIT for that signal. | |
[EFAULT] | |
The status or rusage argument points to an illegal address. (May not be detected before exit of a child process.) | |
[EINTR] | |
The call was interrupted by a caught signal, or the signal did not have the SA_RESTART flag set. | |
The wait and waitpid functions are defined by POSIX; wait4 and wait3 are not specified by POSIX. The WCOREDUMP macro and the ability to restart a pending wait call are extensions to the POSIX interface.
The wait function appeared in AT&T v6 .
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia |