#include<stdio.h> #include<errno.h> #include<unistd.h> int main() { int pid, pipeFD[ 2 ]; char buffer[ 100 ]; if ( pipe( pipeFD ) < 0 ) { printf( "created pipe error/n" ); exit( -1 ); } if( ( pid = fork() ) == 0 ) { close( pipeFD[ 0 ] ); write( pipeFD[ 1 ], "hell", 13 ); write( STDOUT_FILENO, "write done/n", 11 ) ; } else { close( pipeFD[ 1 ] ); read( pipeFD[ 0 ], buffer, 100 ); printf( "%s/n", buffer ); waitpid( pid, NULL, 0 ); } return 0; }