Pass stdout of child to parents stdin
问题 I try to pass the stdout of an program in a child process to the stdin in the parents process. In bash this would look like this: wget "adress"|less My code looks like this: int fd[2]; pid_t child_id; int status; char *args[] = {"wget","-O -",argv[1], NULL}; int pipe(int fd[2]); child_id = fork(); if (child_id == -1) { printf ("Fork error\n"); } if (child_id == 0) { close(fd[0]); int c = dup2(fd[1],1); execl ("/usr/bin/wget", "wget", "-qO-",argv[1], NULL); } else{ waitpid(child_id,&status,0);