#include <stdio.h>
#include <signal.h>
void f( int );
int main () {
int i ;
signal ( SIGINT , f) ;
for (i =0; i <5; i ++) {
printf ( " hello \n " ) ;
sleep (10) ;
}
}
void f( int signum ){
//signal ( SIGINT , f) ;
printf ( " OUCH !\n ") ;
}
I am try to learn handle signals in c. In code above i could not understand the way that function signal works. I understand that when i execute this code when i press control-c function f will be executed and would interrupt the loop.But when i press repeatedly and quickly control-c command sleep would not be executed .Why?