wait(3C)


wait3 -- wait for child process to change state

Synopsis

   #include <sys/wait.h>
   #include <sys/time.h>
   #include <sys/resource.h>
   

pid_t wait3 (int *stat_loc, int options, struct rusage *r_usage);

Description

The wait3 function allows the calling process to obtain status information for specified child processes. See wait(2) for a description of the arguments to wait3.

Note that the following call:

   wait3(stat_loc, options, r_usage);

is equivalent to the call:

   waitpid((pid_t)-1, stat_loc, options);

except that on successful completion, if the r_usage argument to wait3 is not a NULL pointer, the rusage structure to which the third argument points is filled in for the child process identified by the return value.

Return value

If wait3 returns because the status of a child process is available, it returns a value equal to the process ID of the child process for which status is reported. If it returns due to the delivery of a signal to the calling process, -1 is returned and errno is 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, 0 will be returned. Otherwise, (pid_t)-1 is returned, and errno is set to indicate the error.

Errors

The wait3 function will fail if:

ECHILD
The calling process has no existing unwaited-for child processes; or, the process or process group specified by pid does not exist or is not a child of the calling process.

EINTR
The function was interrupted by a signal. The value of the location pointed to by stat_loc is undefined.

EINVAL
The options argument is not valid.

References

exec(2), exit(2), fork(2), pause(2), wait(2), waitpid(2), wstat(5)

Standards conformance

This routine conforms to X/Open System Interfaces and Headers, Issue 4, Version 2.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004