Add philosophe course code without famine, fixed.
[TD_SE.git] / signal / signaux0.c
1 // signaux0.c
2
3 #include <signal.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <unistd.h>
7
8 int count = 0;
9
10 static void action(int sig)
11 {
12 ++count;
13 write(1, "capture du signal SIGINT\n", 26);
14 }
15
16 int main()
17 {
18 // Spécification de l'action du signal
19 signal(SIGINT, action);
20 printf("Debut:\n");
21 do {
22 sleep(1);
23 } while (count < 3);
24 return 0;
25 }