Question: a) Consider the code in Figure 2 (with lines numbered 1 - 34) and answer the questions below related to processes and signals in C.

 a) Consider the code in Figure 2 (with lines numbered 1

a) Consider the code in Figure 2 (with lines numbered 1 - 34) and answer the questions below related to processes and signals in C. 1 #include 2 #include 3 include 4 #include 5 #include 6 #include 7 8 void last_wishes (int s) { 9 puts("Goodbye and have a good day!!! "); 10 exit(1); 11 1 12 int catch_signal(int sig, void (*handler) (int)) { 13 struct sigaction action; 14 action.sa_handler - handler; 15 sigemptyset (&action.sa_mask); 16 action.sa_flags = 0; 17 return sigaction (sig, Gaction, NULL); 18 19 int main() 20 pid_t pidi 21 int stat, 10; 22 catch_signal (SIGINT, last_wishes); 23 if ((pid - fork()) -- 0) 7 24 while (1) 25 i++; 26 printf("Generating message td ", i); 27 1 28 } 29 else! 30 kill (pid, SIGINT); 31 printf(" process was terminated by SIGINT!!! ); 32 } 33 return 0; 34 ] Figure 2 1) Indicate which process(es) handle(s) the signal. Explain your answer by describing when the signal is registered, sent and what happens after. ii) Explain the activities performed by the child process and all its outputs. I) Describe the semantics of line 30 and explain the parameters of the function in relation to the program shown in Figure 2. iv) Complete the statement in line 31 and indicate which process(es) perform(s) this output. [11 marks)

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!