wait

Checks the status of the child process before exiting. A child process is terminated when the parent process terminates.

Format

#include  <wait.h>

pid_t wait  (int *status);

Argument

status
The address of a location to receive the final status of the terminated child. The child can set the status with the exit function and the parent can retrieve this value by specifying status.

Description

This function suspends the parent process until the final status of a terminated child is returned from the child.

On OpenVMS Version 7.0 and higher systems, the wait function is equivalent to waitpid( 0, status, 0 ) if you include <wait.h> and compile with the _POSIX_EXIT feature-test macro set (either with /DEFINE=_POSIX_EXIT or with #define _POSIX_EXIT at the top of your file, before any file inclusions).

Return Values
The process ID (PID) of the terminated child. If more than one child process was created, wait will return the PID of the terminated child that was most recently created. Subsequent calls will return the PID of the next most recently created, but terminated, child. 
- 1  No child process was spawned. 


Previous Page | Next Page | Table of Contents | Index