summaryrefslogtreecommitdiffstats
path: root/src/e_externs_pipes.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/e_externs_pipes.c')
-rw-r--r--src/e_externs_pipes.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/e_externs_pipes.c b/src/e_externs_pipes.c
index 6f24435..f6243e5 100644
--- a/src/e_externs_pipes.c
+++ b/src/e_externs_pipes.c
@@ -44,26 +44,28 @@ static uint8_t
}
static void
- e_pipe_child(const char *fullpath,
- t_com *ptr,
- t_msh *msh)
+ e_pipe_child(char *fullpath[],
+ uint8_t pipe_id,
+ t_com *ptr,
+ t_msh *msh)
{
uint8_t bu_id;
uint8_t ret;
dup_redirs(ptr, msh);
- if (ft_strncmp(fullpath, "builtin", 8) == 0)
+ if (ft_strncmp(fullpath[pipe_id], "builtin", 8) == 0)
{
bu_id = get_builtin_id(ptr->bin, msh);
ret = msh->bu_ptr[bu_id](ptr->argv + 1, msh);
u_eof_fd(msh->fd);
+ s_lpipes_clear(&msh->curr->pipes);
s_line_clear(&msh->curr);
s_destroy(msh);
- ft_memdel((void*)&fullpath);
+ ft_delwords(fullpath);
exit(ret);
}
else
- execve(fullpath, ptr->argv, msh->envp);
+ execve(fullpath[pipe_id], ptr->argv, msh->envp);
/* TODO: handle execve failed */
}
@@ -84,7 +86,7 @@ static size_t
}
static void
- exec_path(const char *fullpath[],
+ e_pipe_exec_path(char *fullpath[],
struct s_lpipes *head,
t_msh *msh)
{
@@ -119,7 +121,7 @@ static void
close(fd[j][FT_READ_END]);
j++;
}
- e_pipe_child(fullpath[i], head->com, msh);
+ e_pipe_child(fullpath, i, head->com, msh);
}
head = head->next;
i++;
@@ -177,6 +179,6 @@ void
rptr = rptr->next;
}
i = 0;
- exec_path((const char**)fullpath, head, msh);
+ e_pipe_exec_path(fullpath, head, msh);
ft_delwords(fullpath);
}