Question: What does the following C program print [4 points] and why [7 points]? Note that emphasis of this question is on your understanding of

What does the following C program print [4 points] and why [7

 

What does the following C program print [4 points] and why [7 points]? Note that emphasis of this question is on your understanding of the signal functionality. State your assumptions where necessary. pid_t pid; void h1(int sig) { } printf("eagle"); kill(pid, SIGUSR2); void h2(int sig) { } printf("sparrow"); exit(0); main() { signal(SIGUSR2, h1); if ((pid fork()) == 0) { signal(SIGUSR2, h2); } kill(getppid(), SIGUSR2); while(1) {}; else { pid_t p; int status; if ((p = wait(&status)) > 0) { printf("pigeon"); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Signal Handlers h1int sig is a signal handler for SIGUSR2 signal It prints eagle and sends SIGUSR2 t... View full answer

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 Programming Questions!