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 tinclude 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, &action, NULL); 18 ) 19 int main() { 20 pid_t pid; 21 int stat, i-0; 22 catch_signal (SIGINT, last_wishes); 23 if ((pid - fork()) -- 0) 24 while (1) 25 i++; 26 printf ("Generating message *d ", i); 27 > 28 ) 29 else { 30 kill (pid, SIGINT); 31 printf(" process was terminated by SIGINT!!! ); 32 ) 33 return 0; 34 1 Figure 2 i) 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. iii) 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

Step: 3

blur-text-image

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

What is operatiing system?

Answered: 1 week ago