This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
TP-TR/chap0/sig.c
Super_JK bd84de1a32 :,)
2022-03-29 17:17:15 +02:00

39 lines
756 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#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. Im 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 ;
}