From 19e9127649b020167cad5d19d8d37c1b062185eb Mon Sep 17 00:00:00 2001 From: yiyingZ Date: Tue, 30 Sep 2014 09:14:12 -0300 Subject: [PATCH] Fixes Issues #7 Make the parent wait until child has finished before printing results of mean() --- mm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm.c b/mm.c index cb330f2..77e09cf 100644 --- a/mm.c +++ b/mm.c @@ -1,6 +1,7 @@ #include #include #include +#include #define debug 0 @@ -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");