diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-05-11 18:00:05 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-05-11 18:00:05 +0200 |
commit | 6d650e0158a70075560fed69b5e07bdbd2bb5f91 (patch) | |
tree | 127f0c96db47d92f48348b2b9b9bb8e521992852 /src/ft_e_externs_pipes.c | |
parent | Almost there (diff) | |
download | 42-minishell-6d650e0158a70075560fed69b5e07bdbd2bb5f91.tar.gz 42-minishell-6d650e0158a70075560fed69b5e07bdbd2bb5f91.tar.bz2 42-minishell-6d650e0158a70075560fed69b5e07bdbd2bb5f91.tar.xz 42-minishell-6d650e0158a70075560fed69b5e07bdbd2bb5f91.tar.zst 42-minishell-6d650e0158a70075560fed69b5e07bdbd2bb5f91.zip |
Nigga what
Diffstat (limited to '')
-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); } } |