From 3a7b348c39b2b28b5d530477b687182000cc70ed Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 11 May 2020 17:10:53 +0200 Subject: It's not pipin' --- src/ft_e_externs_pipes.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ft_e_externs_pipes.c b/src/ft_e_externs_pipes.c index a54e565..773905d 100644 --- a/src/ft_e_externs_pipes.c +++ b/src/ft_e_externs_pipes.c @@ -38,24 +38,24 @@ static void t_msh *msh) { /* TODO: norme */ - pid_t pid; + pid_t pid[2]; int32_t pipefd[2]; int32_t status; pipe(pipefd); - if ((pid = fork()) == 0) + if ((pid[0] = fork()) == 0) { close(pipefd[0]); dup2(pipefd[1], STDOUT_FILENO); ft_e_extern_child(fullpath[0], ptr->one, msh); } - else if (pid < 0) + else if (pid[0] < 0) { /* TODO: handle fork failed */ } else { - if ((pid = fork()) == 0) + if ((pid[1] = fork()) == 0) { close(pipefd[1]); dup2(pipefd[0], STDIN_FILENO); @@ -65,9 +65,9 @@ static void { close(pipefd[0]); close(pipefd[1]); - waitpid(-1, &status, 0); + waitpid(pid[1], &status, 0); } - waitpid(-1, &status, 0); + waitpid(pid[0], &status, 0); msh->ret = WEXITSTATUS(status); } } -- cgit v1.2.3