ASR31-valarche-2021/Exemples/05-Signaux/signal-0.c

27 lines
494 B
C
Raw Permalink Normal View History

2021-10-13 08:43:24 +02:00
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
void sighandler (int signum);
int main(int argc, char *argv[]) {
char buffer[256];
if (signal(SIGTERM, &sighandler) == SIG_ERR) {
printf("Ne peut pas manipuler le signal\n");
exit(1);
}
while (1) {
fgets(buffer, sizeof(buffer), stdin);
printf("Input : %s", buffer);
}
return EXIT_SUCCESS;
}
void sighandler (int signum) {
printf("Masquage du signal SIGTERM\n");
}