#include #include #include #include /* O pai fala e o filho escuta */ /* pai | filho */ int main (void) { pid_t pid; int mypipe[2]; /* Create the pipe. */ pipe (mypipe); /* Create the child process. */ pid = fork (); if (pid == 0) { char s[10]; close (mypipe[1]); dup2(mypipe[0], 0); close(mypipe[0]); scanf("%s", s); printf("%s\n", s); } else { /* This is the parent process. */ FILE* stream_pai; char* s = "hello"; close (mypipe[0]); dup2(mypipe[1], 1); close(mypipe[1]); printf("%s", s); } return 0; }