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)
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(log3, "Child %d has no antidote for poison and will exit \n", myNumber);
break;
}
else
{
......@@ -149,7 +150,7 @@ main(int argc, char * argv[])
*/
/* Ignore newlines and spaces */
if( c == '\n' || (int)c == 32 )
if( c == '\n' || c == 32 )
{
continue;
}
......@@ -172,8 +173,8 @@ main(int argc, char * argv[])
}
else
{
if( c == 'P' )
wait(NULL);
//if( c == 'P' )
// wait(NULL);
pid_t child_id;
......@@ -182,7 +183,7 @@ main(int argc, char * argv[])
/* When you fork, be sure to print the process id of the child
(if the fork succeeds) and an error message otherwise */
switch( fork() )
switch( (child_id = fork()) )
{
case -1:
perror("Child could not be created \n");
......@@ -191,12 +192,12 @@ main(int argc, char * argv[])
gup(log1, log2, pipe_id, getpid());
break;
default:
fputs("Parent process continuing... \n", log1);
fputs("Parent process continuing... \n", log2);
fprintf(log1, "Started child process %d \n", child_id);
fprintf(log2, "Started child process %d \n", child_id);
}
}
}
fprintf(log1, "Program exited normally \n");
fprintf(log2, "Program exited normally \n");
fclose(log1);
......
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