diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-05-11 17:08:01 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-05-11 17:08:01 +0200 |
commit | 2fe6c1f9791b7bb3de02fde7ba31a6f0534edbc6 (patch) | |
tree | 1ba5f544f24362b9408034a25f2aed4b4d6af845 /src | |
parent | New files (diff) | |
download | 42-minishell-2fe6c1f9791b7bb3de02fde7ba31a6f0534edbc6.tar.gz 42-minishell-2fe6c1f9791b7bb3de02fde7ba31a6f0534edbc6.tar.bz2 42-minishell-2fe6c1f9791b7bb3de02fde7ba31a6f0534edbc6.tar.xz 42-minishell-2fe6c1f9791b7bb3de02fde7ba31a6f0534edbc6.tar.zst 42-minishell-2fe6c1f9791b7bb3de02fde7ba31a6f0534edbc6.zip |
Tryna pipe(2)
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_e_externs_pipes.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/ft_e_externs_pipes.c b/src/ft_e_externs_pipes.c index d4d648d..a54e565 100644 --- a/src/ft_e_externs_pipes.c +++ b/src/ft_e_externs_pipes.c @@ -53,22 +53,23 @@ static void { /* TODO: handle fork failed */ } - if ((pid = fork()) == 0) + else { - close(pipefd[1]); - dup2(pipefd[0], STDIN_FILENO); - ft_e_extern_child(fullpath[1], ptr->next->one, msh); - } - /* else */ - /* { */ - close(pipefd[0]); - close(pipefd[1]); - while (wait(&status) != pid) - ; - while (wait(&status) != pid) - ; + if ((pid = fork()) == 0) + { + close(pipefd[1]); + dup2(pipefd[0], STDIN_FILENO); + ft_e_extern_child(fullpath[1], ptr->next->one, msh); + } + else + { + close(pipefd[0]); + close(pipefd[1]); + waitpid(-1, &status, 0); + } + waitpid(-1, &status, 0); msh->ret = WEXITSTATUS(status); - /* } */ + } } void |