The parent process will often want to wait until all child processes have been completed. this can be implemented with the wait() function call.
wait(): Blocks calling process until the child process terminates.
If child process has already teminated, the wait() call returns immediately.
if the calling process has multiple child processes, the function returns when one returns.
waitpid(): Options available to block calling process for a particular child process not the first one.
#include <sys/wait.h>
05 | pid_t pID = <i>set to child process id with call to fork OR:</i> |
14 | pid_t ws = waitpid( pID, &childExitStatus, WNOHANG); |
16 | if ( WIFEXITED(childExitStatus) ) |
20 | cout << "Result of waitpid: Child process exited thus exec failed." << endl; |
No comments:
Post a Comment