Consider the following code:
#include <signal.h>
#include <stdio.h>
void catch ()
{
printf("hi\n");
}
int main()
{
struct sigaction act;
act.sa_handler = catch;
sigaction(SIGINT, &act, NULL);
for(;;);
return 0;
}
When this program is run. The first time I press CTRL-C it prints "hi".
But the second time the program exits. what could be the reason for this?
What I wanted was that the program catch the signal each time it is raised.