#include #include #include #include int main(){ int i; int x1, x2; int ecrit, lu; int p[2]; pipe(p); for (i=0; i<3; i++){ x1 = fork(); if (i==0 && x1==0){ x2 = fork(); if (x2 == 0){ read(p[0],&lu,sizeof(int)); printf("%d received %d\n", getpid(), lu); close(p[0]); } } if (i==1 && x1==0){ x2 = fork(); if (x2==0){ ecrit = getpid(); write(p[1],&ecrit,sizeof(int)); close(p[1]); } } } return EXIT_SUCCESS; }