/*-------------------------------------------------------------------*/ /* testpipeparent2child.c */ /* The pipe system call. */ /*-------------------------------------------------------------------*/ /* Error handling code omitted. */ /* Read and write system call looping omitted. */ /*-------------------------------------------------------------------*/ #include #include int main(int argc, char *argv[]) { int piPipeFd[2]; int iPid; pipe(piPipeFd); iPid = fork(); if (iPid == 0) { char pcBuffer[6]; close(piPipeFd[1]); read(piPipeFd[0], pcBuffer, 6); printf("%s\n", pcBuffer); close(piPipeFd[0]); exit(0); } close(piPipeFd[0]); write(piPipeFd[1], "hello", 6); close(piPipeFd[1]); return 0; } /* Sample execution: --> testpipeparent2child hello --> */