Vidyalelo
Computer Science · Q775

Linux

Engineering and GATE · Computer Science · question 775

Q775

What is the output of this program? #include #include #include void response (int); void response (int sig_no) printf("%s ",sys_siglist[sig_no]); printf("This is singal handler "); int main() pid_t child; int status; child = fork(); switch (child) case -1 : perror("fork"); exit (1); case 0 : kill(getppid(),SIGKILL); printf("I am an orphan process because my parent has been killed by me "); printf("Handler failed "); break; default : signal(SIGKILL,response); wait(&status); printf("The parent process is still alive "); break; return 0;

A.
the child process kills the parent process
Answer
B.
the parent process kills the child process
C.
handler function executes as the signal arrives to the parent process
D.
none of the mentioned

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board