#include <unistd.h>
#include <signal.h>
-#include <wait.h>
+#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
-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);
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;
}