From 31c93c30682c72aae86ddfe8fcc6107ecb2f197f Mon Sep 17 00:00:00 2001 From: lefevres Date: Mon, 6 Dec 2021 17:35:53 +0100 Subject: [PATCH] Add 'ASR3.1/TP06 Redirection tubes ' --- ASR3.1/TP06 Redirection tubes | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 ASR3.1/TP06 Redirection tubes 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