#include #include #include #include #include int main() { char *command1[] = {"ls","ls", ".", NULL}; char *command2[] = {"wc","wc", "-l", NULL}; int p[2]; pipe(p); pid_t pid = fork(); if (pid == 0) { close(p[0]); dup2(p[1], STDOUT_FILENO); execvp(command1[0], &command1[1]); close(p[1]); exit(0); } else{ close(p[1]); dup2(p[0], STDIN_FILENO); //dup2(STDIN_FILENO,p[0]); execvp(command2[0], &command2[1]); close(p[0]); exit(0); } return 0; }