diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_e_externs_pipes.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/ft_e_externs_pipes.c b/src/ft_e_externs_pipes.c index df460df..3d21832 100644 --- a/src/ft_e_externs_pipes.c +++ b/src/ft_e_externs_pipes.c @@ -46,9 +46,9 @@ static void pipe(pipefd); if ((pid = fork()) == 0) { - close(pipefd[FT_WRITE_END]); - dup2(pipefd[FT_READ_END], STDOUT_FILENO); + dup2(pipefd[FT_WRITE_END], STDOUT_FILENO); close(pipefd[FT_READ_END]); + close(pipefd[FT_WRITE_END]); ft_e_extern_child(fullpath[0], ptr->one, msh); } else if (pid < 0) @@ -61,17 +61,20 @@ static void { dup2(pipefd[FT_READ_END], STDIN_FILENO); close(pipefd[FT_WRITE_END]); - close(pipefd[FT_WRITE_END]); + close(pipefd[FT_READ_END]); ft_e_extern_child(fullpath[1], ptr->next->one, msh); } else if (pid < 0) { /* TODO: handle fork failed */ } - close(pipefd[FT_READ_END]); - close(pipefd[FT_WRITE_END]); - waitpid(-1, &status, 0); - waitpid(-1, &status, 0); + else + { + close(pipefd[FT_READ_END]); + close(pipefd[FT_WRITE_END]); + waitpid(pid, &status, 0); + } + waitpid(pid, &status, 0); msh->ret = WEXITSTATUS(status); } } |