Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

Discuss the steps in human resource planning.

Answered: 1 week ago