#include #include #include #include #include #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; }