⟩ What happens as the SIGINT signal hits the running process of this program? #include<stdio.h> #include<signal.h> #include<stdlib.h> int main() { pid_t child; signal(SIGINT,SIG_IGN); child=fork(); switch(child){ case -1 perror("fork"); exit(1); case 0 while(1){ printf("Child Processn"); sleep(1); } break; default while(1){ printf("Parent Processn"); pause(); } break; } return 0; } a) child process terminates b) parent process terminates c) both child and parent process ignores the signal d) none of the mentioned
c) both child and parent process ignores the signal
Explanation:
If a process ignores a signal then by default its child also ignores that signal.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
Parent Process
Child Process
Child Process
^CChild Process
^CChild Process
^CChild Process
^Z
[3]+ Stopped ./san
[root@localhost signal]#