-
-
Save MosheBerman/5646676 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Loop through the processes and wait for them | |
* to terminate. Then print the childid, and the | |
* the pid. | |
*/ | |
int status = NULL; | |
for (int i = 0; i < n; i++) | |
{ | |
/* Wait for the child process | |
* and grab it's status info | |
*/ | |
status = NULL; | |
/* Wait for the first process | |
* that terminates to do so. | |
*/ | |
waitpid(-1, &status, 0); | |
int childid = -1; | |
if(WIFEXITED(status)) | |
{ | |
childid = WEXITSTATUS(status); | |
/* Log the results | |
*/ | |
time = elapsedTime(1); | |
printf("%li: Child %i, pid = %i, terminated\n", time, childid, PIDs[childid]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment