Part II (8 points) int counter = 0; void handler(int sig) { counter++; } int main() { int i; signal(SIGCHLD, handler); for (i = 0; i < 5; i ++){ if (fork() == 0){ } } exit(0); /* wait for all children to die */ while (wait(NULL) != -1); printf("counter = %d\n", counter); return 0; } A. Does the program output the same value of counter every time we run it? Yes No B. If the answer to A is Yes, indicate the value of the counter variable. Otherwise, list all possible values of the counter variable. Answer: counter =
Part II (8 points) int counter = 0; void handler(int sig) { counter++; } int main() { int i; signal(SIGCHLD, handler); for (i = 0; i < 5; i ++){ if (fork() == 0){ } } exit(0); /* wait for all children to die */ while (wait(NULL) != -1); printf("counter = %d\n", counter); return 0; } A. Does the program output the same value of counter every time we run it? Yes No B. If the answer to A is Yes, indicate the value of the counter variable. Otherwise, list all possible values of the counter variable. Answer: counter =
Related questions
Question
![Part II (8 points)
int counter = 0;
void handler(int sig)
{
counter++;
}
int main()
{
int i;
signal(SIGCHLD, handler);
for (i = 0; i < 5; i ++){
if (fork() == 0){
}
}
exit(0);
/* wait for all children to die */
while (wait(NULL) != -1);
printf("counter = %d\n", counter);
return 0;
}
A. Does the program output the same value of counter every time we run it?
Yes
No
B. If the answer to A is Yes, indicate the value of the counter variable. Otherwise, list all possible values
of the counter variable.
Answer: counter =](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3b25bdcc-1f5e-4716-88d3-d1e15ee2df25%2Fda0a0ef5-a74f-4836-baec-8443761703dc%2Fy13kiv_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Part II (8 points)
int counter = 0;
void handler(int sig)
{
counter++;
}
int main()
{
int i;
signal(SIGCHLD, handler);
for (i = 0; i < 5; i ++){
if (fork() == 0){
}
}
exit(0);
/* wait for all children to die */
while (wait(NULL) != -1);
printf("counter = %d\n", counter);
return 0;
}
A. Does the program output the same value of counter every time we run it?
Yes
No
B. If the answer to A is Yes, indicate the value of the counter variable. Otherwise, list all possible values
of the counter variable.
Answer: counter =
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)