1 Answers
Registering Signal Handlers
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void handler_for_alrm(int signo) {
printf("You can't interrupt me\n");
time_t t1;
time(&t1); //t1=time(NULL);
printf("Current time is %s\n", ctime(&t1);
alarm(1);
}
int main() {
printf("Welcome,pid=%d\n", getpid());
signal(AIGALRM, handler_for_alrm);
alarm(5);
while (1)
pause();
return 0;
}