What is the output of the below code?
void sig_handler ( int signum) {
printf(“Handled the signal\n”);
}
int main() {
int pid;
signal (SIGKILL, sig_handler);
pid = fork();
if (pid==0) {
kill(getppid(), SIGKILL);
exit(0);
} else {
sleep(20);
}
return 0;
}
void sig_handler ( int signum) {
printf(“Handled the signal\n”);
}
int main() {
int pid;
signal (SIGKILL, sig_handler);
pid = fork();
if (pid==0) {
kill(getppid(), SIGKILL);
exit(0);
} else {
sleep(20);
}
return 0;
}A. Error child cannot send a SIGKILL signal to parent
B. Parent goes to the signal handler, prints handled the signal and goes back to sleep
C. Parent goes to the signal handler, prints handled the signal and exits
D. Parent exits without going to the signal handler
Answer: Option D
Related Questions on Linux
What command is used to count the total number of lines, words, and characters contained in a file?
A. countw
B. wcount
C. wc
D. count p
E. None of the above
What command is used with vi editor to delete a single character?
A. x
B. y
C. a
D. z
E. None of the above

Join The Discussion