diff --git a/ASR3.1/TP06 Redirection tubes b/ASR3.1/TP06 Redirection tubes new file mode 100644 index 0000000..55ebcb0 --- /dev/null +++ b/ASR3.1/TP06 Redirection tubes @@ -0,0 +1,49 @@ +#include +#include +#include +#include + + +int main(int argc, char const *argv[]){ + + int p[2]; + pipe (p); + pid_t pid = getpid(); + + + /*Pf1 -*/ + if (fork() == 0) { + printf("processeur pf1\n"); + + /*pf1f1*/ + if (fork() == 0) { + + read(p[0], &pid, 1 ); + + while (1) { + sleep(3); + printf("PID : %ld\n", pid); + } + + } + + close (p[0]); + + } + + /*Pf2 -> écrit*/ + if (fork() == 0) { + + //printf("while ok\n"); + + write (p[1], &pid, 1); + + close (p[1]); + + } + + + + + return 0; +} \ No newline at end of file