#include
#include
void ALARMhandler(int sig)
{
signal(SIGALRM, SIG_IGN); /* ignore this signal */
printf(\"H
You are not installing the signal handler first.
You need to tell the system that you want to handle the signal before actually receiving it, so you need to call signal() from main before the signal comes.
int main(int argc, char *argv[])
{
signal(SIGALRM, ALARMhandler); /* install the handler */
alarm(2); /* set alarm clock */
while (1);
}