previous | start | next

Waiting for a Child Process

The waitpid has several options, the simplest is to wait for any child it has created to terminate (either normally or abnormally)

      int pid;
      int status;
      pid = waitpid(-1, &status, 0);
   

The -1 means wait for any child process to terminate.

The second parameter can be 0. In that case it is ignored. If not zero the integer 'status' contains information about how the child terminated and its exit or return value if it terminated normally.



previous | start | next