*
This commit is contained in:
17
SCR3.1/devoir27/ex1/gdf1.c
Normal file
17
SCR3.1/devoir27/ex1/gdf1.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(void){
|
||||
pid_t x, x1, x2, x3;
|
||||
x1 = fork();
|
||||
if (x1 == 0){
|
||||
x2=fork();
|
||||
if (x2 == 0)
|
||||
x = fork();
|
||||
x3=fork();
|
||||
}
|
||||
}
|
||||
|
||||
|
1
SCR3.1/devoir27/ex1/gdf2.txt
Normal file
1
SCR3.1/devoir27/ex1/gdf2.txt
Normal file
@@ -0,0 +1 @@
|
||||
La commande "kill -TERM 30544" provoque l'arrêt forcé du processus 30544, à cause du signal de terminaison envoyé
|
38
SCR3.1/devoir27/ex1/gdf3.c
Normal file
38
SCR3.1/devoir27/ex1/gdf3.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#define BUF_SIZE 128
|
||||
|
||||
int main(void){
|
||||
pid_t x, x1, x2, x3;
|
||||
int p[2];
|
||||
char buf;
|
||||
assert(pipe(p) != -1);
|
||||
x1 = fork();
|
||||
if (x1 == 0){
|
||||
x2=fork();
|
||||
if (x2 == 0){
|
||||
x = fork();
|
||||
if (x == 0){
|
||||
close(p[0]);
|
||||
dup2(p[1], 1);
|
||||
close(p[1]);
|
||||
printf("%d", getpid());
|
||||
}
|
||||
x3=fork();
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
if (x1 > 0){
|
||||
close(p[1]);
|
||||
while(read(p[0], &buf, sizeof(char)) > 0)
|
||||
write(1, &buf, sizeof(char));
|
||||
}
|
||||
close(p[0]);
|
||||
printf("\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user