Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Make a fork tree diagram and explain. int pid = 0; void sigchild(int s) { printf(wow); fflush(stdout); if (pid) { kill(pid, SIGHUP); } } void
Make a fork tree diagram and explain. int pid = 0; void sigchild(int s) { printf("wow"); fflush(stdout); if (pid) { kill(pid, SIGHUP); } } void sighup(int s) { printf("get"); fflush(stdout); if (!pid) { kill(getppid(), SIGHUP); } } int main() { int status; pid_t p; Signal(SIGCHLD, sigchild); Signal(SIGHUP, sighup); int i; for (i = 0; i <= 2; i++) { if ((pid = fork()) == 0) { kill(getppid(), SIGHUP); // getppid returns parents pid sleep(1); exit(0); } sleep(1); } if ((p = wait(&status)) > 0) { fprintf(stderr, "low"); } else { fprintf(stderr, "high"); } fflush(stdout); return 0; }
In this program, a parent process (P) forks child processes C1, C2, and C3.
Can C1 print "get"?
_____________(Y/N)
Can C2 print "get"?
____________(Y/N)
What is the maximum number of times P might print "get"?
__________(number require)
What is the maximum number of times C3 might print "get"?
___________(number require)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started