Signal Handling Interview Preparation Guide
Download PDF

Signal Handling frequently Asked Questions in various Linux Signal Handling job Interviews by interviewer. The set of questions here ensures that you offer a perfect answer posed to you. So get preparation for your new job hunting

21 Linux Signal Handling Questions and Answers:

7 :: This program will print:

#include<stdio.h>
#include<signal.h>
#include<unistd.h>

void response (int);
void response (int sig_no)
{
printf("%s is workingn",sys_siglist[sig_no]);
}
int main()
{
alarm(5);
sleep(50);
printf("googlen");
signal(SIGALRM,response);
return 0;
}
a) "google"
b) "Alarm clock"
c) nothing
d) none of the mentioned

b) "Alarm clock"
Explanation:After 5 seconds of the execution of this program, the signal SIGALRM hits the process and handler executes.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
Alarm clock
[root@localhost google]#

9 :: Which one of the following is not true about this program?

#include<stdio.h>
#include<signal.h>

void response (int);
void response (int signo)
{
printf("%sn",sys_siglist[signo]);
signal(SIGSEGV,SIG_IGN);
}
int main()
{
signal (SIGSEGV,response);
char *str;
*str = 10;
return 0;
}
a) kernel sends SIGSEGV signal to a process as segmentation fault occurs
b) in this process signal handler will execute only one time of recieving the signal SIGSEGV
c) both (a) and (b)
d) none of the mentioned

d) none of the mentioned
Explanation:
In this process the segmentation fault occurs because the memory is not allocated to the pointer *str.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
Segmentation fault
Segmentation fault (core dumped)
[root@localhost google]#