X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TD3%2Fexo4%2Fexo4.c;h=f066e52354d9cd04d1de94cc74b9ba69778aff10;hb=f19ad1ea77a4b2d5e6e73aebcf71ba22b69b4618;hp=e835d0d44505cf72cfdb4acff9d5f8b13d379417;hpb=01d700ab53176f4c319136e4ab9023018ffd3721;p=TD_SE.git diff --git a/TD3/exo4/exo4.c b/TD3/exo4/exo4.c index e835d0d..f066e52 100644 --- a/TD3/exo4/exo4.c +++ b/TD3/exo4/exo4.c @@ -1,22 +1,28 @@ #include #include -#include +#include #include #include -void sigintP() +static void sigintP() { + printf("pid=%d\n", getpid()); + signal(SIGINT, sigintP); } -void sigalrm() +static void sigalrm() { + exit(1); } -void sigintF() +static void sigintF() { + signal(SIGINT, SIG_IGN); + signal(SIGALRM, sigalrm); + alarm(5); } -void sigchld() +static void sigchld() { int status; wait(&status); @@ -29,14 +35,13 @@ int main(void) if (fork() == 0) { signal(SIGINT, sigintF); while (1) { - printf("ici fils \n"); + printf("ici fils\n"); sleep(1); } } while (1) { signal(SIGINT, sigintP); - printf("ici pere \n"); + printf("ici pere\n"); sleep(1); } - return 0; }