Signal Handling Question:
Download Job Interview Questions and Answers PDF
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
Answer:
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]#
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]#
Download Linux Signal Handling Interview Questions And Answers
PDF