Fixed bug in assignment 3 (fork/pipe) of OS.

parent f3205726
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
child.log* child.log*
*.swp *.swp
fishbones fishbones
fish
PROG = fish PROG = fish
CC = gcc CC = gcc
CFLAGS = -std=gnu99 -pedantic -Wall -Wextra -O3 CFLAGS = -std=c99 -pedantic -Wall -Wextra -O3 -D_POSIX_SOURCE
OFILES = fishbones.o OFILES = fishbones.o
RM = rm -f RM = rm -f
......
...@@ -69,7 +69,8 @@ static void gup(FILE * log1, FILE * log2, int pipe_id[2], int myNumber) ...@@ -69,7 +69,8 @@ static void gup(FILE * log1, FILE * log2, int pipe_id[2], int myNumber)
fprintf(log1, "antidote used (%d left) \n", antidote); fprintf(log1, "antidote used (%d left) \n", antidote);
fprintf(log2, "antidote used (%d left) \n", antidote); fprintf(log2, "antidote used (%d left) \n", antidote);
fprintf(log3, "antidote used (%d left) \n", antidote); fprintf(log3, "antidote used (%d left) \n", antidote);
break; break;
}
} }
else if( c == 'A' ) else if( c == 'A' )
{ {
...@@ -193,7 +194,7 @@ main(int argc, char * argv[]) ...@@ -193,7 +194,7 @@ main(int argc, char * argv[])
perror("Child could not be created \n"); perror("Child could not be created \n");
exit(1); exit(1);
case 0: case 0:
gup(log1, log2, pipe_id, child_id); gup(log1, log2, pipe_id, kiddoCount);
break; break;
default: default:
puts("Parent process continuing..."); puts("Parent process continuing...");
......
bindkey ^c at "#" kill
split -v
screen watch cat child.log1
focus
split -v
screen watch cat child.log2
focus
screen watch cat child.log3
#!/bin/bash
if [ "`which screen`" = '' ]; then
echo "GNU screen is missing. I'll now trying to install screen using apt-get.";
echo "The installation of GNU screen requires sudo-rights: ";
sudo apt-get install screen ;
fi;
screen -c screenrc
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