39 lines
756 B
C
39 lines
756 B
C
#include <stdio.h> // p r i n t f ( . . )
|
||
#include <stdlib.h> // EXIT_SUCCESS
|
||
#include <signal.h> // s i g n a l ( . . )
|
||
#include <unistd.h>
|
||
|
||
|
||
int signb = 1;
|
||
|
||
void handler ( int signum ) {
|
||
if ( signum == SIGINT ){
|
||
if (signb == 1 )
|
||
printf ( "Just give me a moment.\n" );
|
||
else if (signb == 2)
|
||
printf("I said I need a moment !\n");
|
||
else {
|
||
printf("Fine. I’m out of here.\n");
|
||
exit(EXIT_SUCCESS);
|
||
}
|
||
signb +=1;
|
||
}
|
||
}
|
||
|
||
unsigned int string_length ( char string []){
|
||
unsigned int i = 0;
|
||
while (string[i++] != '\0');
|
||
return i-1;
|
||
|
||
}
|
||
|
||
int main ( int argc , char * argv []) {
|
||
signal ( SIGINT , handler );
|
||
|
||
while (1) {
|
||
pause();
|
||
//printf("Waiting loop resumed .\n");
|
||
}
|
||
return EXIT_SUCCESS ;
|
||
}
|