Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Answer the following questions related to the functionality of the below C-progr

ID: 3820581 • Letter: A

Question

Answer the following questions related to the functionality of the below C-program that we discussed in class. Assume INPUTLEN to be 100. main (int ac, char *av void inthandler (int); void guithandler (int); char input INPUTLEN]; int nchars signal SIGINT, inthandler signal(SIGQUIT, quithandler; do Type a message "); nchars read(0, input, (INPUTLEN 1)) if nchars -1 read returned an error"); error else input Incharsl 310; printf("You typed: %s", input); while nput, "quit", 4) 30); void inthandler(int s) printf(" Received Signal %d waiting n", s); slee printf(" Leaving inthandler n"); void quit handler(int s) rint Received Signal %d waiting n", s); sleep(3) printf(" Leaving quithandler In");

Explanation / Answer

1) When process is in SIGINT handler and SIGQUIT is generated , process executes SIGQUIT handler and prints

Received Signal 20......waiting                                                                                                                               

Leaving quithandler

and then it is quit from the SIGINT handler and we can see message "Leaving inthandler"

When we install signal handler , they are global and can be handler anywhere in the program.

2) When process is in SIGINT handler , and SIGINT generated it executes present signal handler and after coming out of the signal handler , again SIGINT handler will be executed.. How many times SIGINT gerenated that many times handler will be executed after coming out of present SIGINT handler.

3) Even when program is blocked for user input , signla handler will be executed as they have highest priority.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote