From 6d650e0158a70075560fed69b5e07bdbd2bb5f91 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 11 May 2020 18:00:05 +0200 Subject: Nigga what --- src/ft_e_externs_pipes.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/ft_e_externs_pipes.c') 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); } } -- cgit v1.2.3