#include #include #include #define BUFSIZE 30 int main() { int pipe_file_descriptors[2]; char buf[BUFSIZE]; pipe( pipe_file_descriptors ); if ( fork() == 0 ) { printf( " CHILD: reading from pipe\n" ); read( pipe_file_descriptors[0], buf, BUFSIZE ); printf( " CHILD: read \"%s\"\n", buf ); } else { printf( "PARENT: writing to the pipe\n" ); write( pipe_file_descriptors[1], "test", BUFSIZE ); printf( "PARENT: finished writing\n" ); wait( NULL ); } return 0; }