Basically, I have this function. After fgets I want the parent to make the child stop by changing its play variable to 0. How would I do that?
void readQuestion(char * question) {
int play = 1;
char inputline[256];
int s;
char * holder;
int p = fork();
if (p == 0) {
while(play) {
holder = strsep(&question," ");
if(holder) {
printf("%s\n",holder);
sleep(1);
}
else{
play = 0;
}
}
}
else {
fgets(inputline,256,stdin);
printf("%s",inputline);
kill();
}
}
To do that you want to take one of two approaches…