repositories
/
TD_SE.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Headers include fix for Mac OS X.
[TD_SE.git]
/
TD3
/
exo4
/
exo4.c
diff --git
a/TD3/exo4/exo4.c
b/TD3/exo4/exo4.c
index e835d0d44505cf72cfdb4acff9d5f8b13d379417..f066e52354d9cd04d1de94cc74b9ba69778aff10 100644
(file)
--- a/
TD3/exo4/exo4.c
+++ b/
TD3/exo4/exo4.c
@@
-1,22
+1,28
@@
#include <unistd.h>
#include <signal.h>
#include <unistd.h>
#include <signal.h>
-#include <wait.h>
+#include <
sys/
wait.h>
#include <stdio.h>
#include <stdlib.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);
{
int status;
wait(&status);
@@
-29,14
+35,13
@@
int main(void)
if (fork() == 0) {
signal(SIGINT, sigintF);
while (1) {
if (fork() == 0) {
signal(SIGINT, sigintF);
while (1) {
- printf("ici fils
\n");
+ printf("ici fils\n");
sleep(1);
}
}
while (1) {
signal(SIGINT, sigintP);
sleep(1);
}
}
while (1) {
signal(SIGINT, sigintP);
- printf("ici pere
\n");
+ printf("ici pere\n");
sleep(1);
}
sleep(1);
}
- return 0;
}
}