Skip to content

Commit

Permalink
Fixes Issues smuos#7 Make the parent wait until child has finished be…
Browse files Browse the repository at this point in the history
…fore printing results of mean()
  • Loading branch information
yiyingZ committed Sep 30, 2014
1 parent 5e861a4 commit 19e9127
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mm.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>

#define debug 0

Expand Down Expand Up @@ -80,6 +81,9 @@ int main(int argc, char *argv[]) {
fprintf(stdout, "The median value is %lf.\n",median(pt,length));
}else if (rc ==1){
//if rc equal to 1 means fork succeed, the parent is processing
//Issues #7 Make the parent wait until child has finished before pring the results of mean()
int wc = wait(NULL);
printf("I am waiting for my child. wc(:%d)\n",wc);
//let parent process print the result of mean()
//Issues#6 Parent process should print the results of mean()
fprintf(stdout,"This is parent processing!\n");
Expand Down

0 comments on commit 19e9127

Please sign in to comment.