Elementary System Calls - Wait() and Waitpid()

Wait function suspends the execution of the calling process until one of its children terminates.

Waitpid suspends execution of the calling process until a child specified by pid argument has changed state.

Wait():

  • Wait() continues to block the caller until a child process terminates.
  • If there are more than one child running, wait() returns the first time one of the parent's offspring exists
  • It doesn't support job control.

Waitpid():

  • It can be either blocking or non-blocking:
if 0, blocking
if WNOHANG, non-blocking
It is flexible
It waits for child process if pid is -1
It waits for child of greater process id if pid>0
It waits for any child whose process group ID equals that of the calling process if pid equals to 0.
It waits for any child whose process group ID equals that absolute value of pid. 
  • It supports job control. 

Post a Comment

0 Comments