MentOS  0.8.0
The Mentoring Operating System
Functions
waitpid.c File Reference

Functions

pid_t waitpid (pid_t pid, int *status, int options)
 Suspends the execution of the calling thread until a child specified by pid argument has changed state. More...
 
pid_t wait (int *status)
 Suspends the execution of the calling thread until ANY child has changed state. More...
 

Detailed Description

Function Documentation

◆ wait()

pid_t wait ( int *  status)

Suspends the execution of the calling thread until ANY child has changed state.

Parameters
statusVariable where the new status of the child is stored.
Returns
On error, -1 is returned, otherwise it returns the pid of the child that has unlocked the wait.

◆ waitpid()

pid_t waitpid ( pid_t  pid,
int *  status,
int  options 
)

Suspends the execution of the calling thread until a child specified by pid argument has changed state.

Parameters
pidSe details below for more information.
statusVariable where the new status of the child is stored.
optionsWaitpid options.
Returns
On error, -1 is returned, otherwise it returns the pid of the child that has unlocked the wait.

By default, waitpid() waits only for terminated children, but this behavior is modifiable via the options argument, as described below. The value of pid can be:

  • 1 meaning wait for any child process. 0 meaning wait for any child process whose process group ID is equal to that of the calling process. > 0 meaning wait for the child whose process ID is equal to the value of pid.