Commit 34bffcda authored by Taddeüs Kroes's avatar Taddeüs Kroes

- Modified some log messages and shell output to make more sense.

parent 8471c08b
...@@ -57,6 +57,7 @@ static void gup(FILE * log1, FILE * log2, int pipe_id[2], int myNumber) ...@@ -57,6 +57,7 @@ static void gup(FILE * log1, FILE * log2, int pipe_id[2], int myNumber)
fprintf(log1, "Child %d has no antidote for poison and will exit \n", myNumber); fprintf(log1, "Child %d has no antidote for poison and will exit \n", myNumber);
fprintf(log2, "Child %d has no antidote for poison and will exit \n", myNumber); fprintf(log2, "Child %d has no antidote for poison and will exit \n", myNumber);
fprintf(log3, "Child %d has no antidote for poison and will exit \n", myNumber); fprintf(log3, "Child %d has no antidote for poison and will exit \n", myNumber);
break;
} }
else else
{ {
...@@ -149,7 +150,7 @@ main(int argc, char * argv[]) ...@@ -149,7 +150,7 @@ main(int argc, char * argv[])
*/ */
/* Ignore newlines and spaces */ /* Ignore newlines and spaces */
if( c == '\n' || (int)c == 32 ) if( c == '\n' || c == 32 )
{ {
continue; continue;
} }
...@@ -172,8 +173,8 @@ main(int argc, char * argv[]) ...@@ -172,8 +173,8 @@ main(int argc, char * argv[])
} }
else else
{ {
if( c == 'P' ) //if( c == 'P' )
wait(NULL); // wait(NULL);
pid_t child_id; pid_t child_id;
...@@ -182,7 +183,7 @@ main(int argc, char * argv[]) ...@@ -182,7 +183,7 @@ main(int argc, char * argv[])
/* When you fork, be sure to print the process id of the child /* When you fork, be sure to print the process id of the child
(if the fork succeeds) and an error message otherwise */ (if the fork succeeds) and an error message otherwise */
switch( fork() ) switch( (child_id = fork()) )
{ {
case -1: case -1:
perror("Child could not be created \n"); perror("Child could not be created \n");
...@@ -191,8 +192,8 @@ main(int argc, char * argv[]) ...@@ -191,8 +192,8 @@ main(int argc, char * argv[])
gup(log1, log2, pipe_id, getpid()); gup(log1, log2, pipe_id, getpid());
break; break;
default: default:
fputs("Parent process continuing... \n", log1); fprintf(log1, "Started child process %d \n", child_id);
fputs("Parent process continuing... \n", log2); fprintf(log2, "Started child process %d \n", child_id);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment