diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-06-26 18:33:25 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-06-26 18:33:25 +0200 |
commit | 1e2d0dd6223537dfd2442be788799b0af5ac2b3d (patch) | |
tree | 71b648a9f313b170bbaf2afee418f8c9e48ea7a6 /src | |
parent | Linux test sec pls (diff) | |
download | 42-minishell-1e2d0dd6223537dfd2442be788799b0af5ac2b3d.tar.gz 42-minishell-1e2d0dd6223537dfd2442be788799b0af5ac2b3d.tar.bz2 42-minishell-1e2d0dd6223537dfd2442be788799b0af5ac2b3d.tar.xz 42-minishell-1e2d0dd6223537dfd2442be788799b0af5ac2b3d.tar.zst 42-minishell-1e2d0dd6223537dfd2442be788799b0af5ac2b3d.zip |
It works NICE norm later
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_e_externs_pipes.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/ft_e_externs_pipes.c b/src/ft_e_externs_pipes.c index 277abb4..c9268ac 100644 --- a/src/ft_e_externs_pipes.c +++ b/src/ft_e_externs_pipes.c @@ -15,6 +15,8 @@ #include <stdlib.h> #include <stdint.h> #include <unistd.h> +#include <string.h> +#include <errno.h> #include "ft_d_define.h" #include "ft_e_externs_next.h" @@ -70,15 +72,16 @@ static void i++; } i = 0; - while (i < pipes) + while (i <= pipes) { - pid = fork(); - if (pid == 0) + if ((pid = fork()) == 0) { if (i != 0) dup2(fd[i - 1][FT_WRITE_END], STDIN_FILENO); if (i != pipes) + { dup2(fd[i][FT_READ_END], STDOUT_FILENO); + } j = 0; while (j < pipes) { @@ -98,6 +101,9 @@ static void close(fd[i][FT_READ_END]); i++; } + /* while (wait(&status) != pid) */ + /* ; */ + /* msh->ret = WEXITSTATUS(status); */ waitpid(pid, &status, 0); msh->ret = WEXITSTATUS(status); } @@ -116,9 +122,9 @@ void head = ptr; rptr = ptr; pipes = ft_e_get_pipes_count(head); - if (!(fullpath = (char**)malloc((pipes + 1) * sizeof(char*)))) + if (!(fullpath = (char **)malloc((pipes + 2) * sizeof(char *)))) ft_fail_alloc(msh); - fullpath[pipes] = NULL; + fullpath[pipes + 1] = NULL; i = 0; while (rptr != NULL) { @@ -137,11 +143,6 @@ void rptr = rptr->next; } i = 0; - while (fullpath[i]) - { - ft_printf("[%s]\n", fullpath[i]); - i++; - } ft_exec_path((const char**)fullpath, head, msh); ft_delwords(fullpath); } |