#include"myHeader.h"
void isr(int n)
{
printf("ALARM.....\n");
alarm(2);
}
main()
{
struct sigaction v;
printf("%d\n",getpid());
alarm(5);
v.sa_handler=isr;
v.sa_flags=SA_RESETHAND;
v.sa_flags=0;
sigemptyset(&v.sa_mask);
sigaction(SIGALRM,&v,NULL);
printf("ALARM is set...\n");
printf("in infinite loop....\n");
while(1);
}
OutPut:
madan@madan-Lenovo-G570:~/madan/osconcepts$ ./a.out
5876
ALARM is set...
in infinite loop....
ALARM.....
ALARM.....
ALARM.....
ALARM.....
ALARM.....
ALARM.....
ALARM.....
ALARM.....
ALARM.....
ALARM.....
ALARM.....
ALARM.....
^C