Answers

Question and Answer:

  Home  Linux Signal Handling

⟩ What will happen as we press the "Ctrl+c" key after running this program? #include<stdio.h> #include<signal.h> void response (int); void response (int sig_no) { printf("Linuxn"); } int main() { signal(SIGINT,response); while(1){ printf("googlen"); sleep(1); } return 0; } a) the string "Linux" will print b) the process will be terminated after printing the string "Linux" c) the process will terminate d) none of the mentioned

a) the string "Linux" will print

Explanation:

The signal handler function "response" executes after recieving the signal SIGINT.

Output:

[root@localhost google]# gcc -o san san.c

[root@localhost google]# ./san

google

google

google

^CLinux

google

google

^CLinux

google

google

^CLinux

google

^Z

[2]+ Stopped ./san

[root@localhost google]#

 204 views

More Questions for you: