Go to the previous, next section.

BSD Process Wait Functions

The GNU library also provides these related facilities for compatibility with BSD Unix. BSD uses the union wait data type to represent status values rather than an int. The two representations are actually interchangeable; they describe the same bit patterns. The GNU C Library defines macros such as WEXITSTATUS so that they will work on either kind of object, and the wait function is defined to accept either type of pointer as its status_ptr argument.

These functions are declared in `sys/wait.h'.

Data Type: union wait

This data type represents program termination status values. It has the following members:

int w_termsig
The value of this member is the same as the result of the WTERMSIG macro.

int w_coredump
The value of this member is the same as the result of the WCOREDUMP macro.

int w_retcode
The value of this member is the same as the result of the WEXITSTATUS macro.

int w_stopsig
The value of this member is the same as the result of the WSTOPSIG macro.

Instead of accessing these members directly, you should use the equivalent macros.

Function: pid_t wait3 (union wait *status_ptr, int options, struct rusage *usage)

If usage is a null pointer, wait3 is equivalent to waitpid (-1, status_ptr, options).

If usage is not null, wait3 stores usage figures for the child process in *rusage (but only if the child has terminated, not if it has stopped). See section Resource Usage.

Function: pid_t wait4 (pid_t pid, union wait *status_ptr, int options, struct rusage *usage)

If usage is a null pointer, wait4 is equivalent to waitpid (pid, status_ptr, options).

If usage is not null, wait4 stores usage figures for the child process in *rusage (but only if the child has terminated, not if it has stopped). See section Resource Usage.

Go to the previous, next section.