#include #include #include main() { int pfd[2]; if(pipe(pfd) == -1) err_sys("pipe"); switch(fork()) { case -1: err_sys("fork"); case 0: if (close(1) == -1) err_sys("close"); if (dup(pfd[1]) != 1) err_sys("dup"); if (close(pfd[0]) == -1 || close(pfd[1]) == -1) err_sys("close2"); execlp("ls", "ls", NULL); err_sys("execl1"); } switch(fork()) { case -1:err_sys("fork"); case 0: if(close(0) == -1) err_sys("close3"); if (dup(pfd[0]) != 0) err_sys("dup2"); if (close(pfd[0]) == -1 || close(pfd[1]) == -1) err_sys("close4"); execlp("wc", "wc", NULL); err_sys("execl2"); } if (close(pfd[0]) == -1 || close(pfd[1]) == -1) err_sys("close5"); wait(NULL) ; }