Here is my code:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
static void sigint_handler(int signo){
printf("%s\n", "hello world!");
for(;;){
pause();
}
}
int main()
{
signal(SIGINT, sigint_handler);
for(;;){
pause();
}
return 0;
}
And in action:
Korays-MacBook-Pro:~ koraytugay$ gcc tugay.c
Korays-MacBook-Pro:~ koraytugay$ ./a.out
^Chello world!
^C^C^C^C^C^C
Why don't I see the hello world message after I hit CTRL + C for the second, third, forth time..?
My understanding is the process should catch CTRL C again, but obviously it is wrong. But why?