Commit | Line | Data |
---|---|---|
c3a3595d JB |
1 | // signaux0.c |
2 | ||
3 | #include <signal.h> | |
4 | #include <stdio.h> | |
5 | #include <stdlib.h> | |
6 | #include <unistd.h> | |
7 | ||
151a0f56 | 8 | static int count = 0; |
c3a3595d JB |
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 | } |