Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!