summaryrefslogtreecommitdiffstats
path: root/src/e_pipes_next.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-10-05 15:45:37 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-10-05 15:45:37 +0200
commit2acbbf9cf6e60822a973bbd28ea6acbbbe47a1a7 (patch)
tree6ff5b0c55217c358f3fa1c76cdacd9505e96ca0d /src/e_pipes_next.c
parentpipes update (diff)
download42-minishell-2acbbf9cf6e60822a973bbd28ea6acbbbe47a1a7.tar.gz
42-minishell-2acbbf9cf6e60822a973bbd28ea6acbbbe47a1a7.tar.bz2
42-minishell-2acbbf9cf6e60822a973bbd28ea6acbbbe47a1a7.tar.xz
42-minishell-2acbbf9cf6e60822a973bbd28ea6acbbbe47a1a7.tar.zst
42-minishell-2acbbf9cf6e60822a973bbd28ea6acbbbe47a1a7.zip
Update
Diffstat (limited to 'src/e_pipes_next.c')
-rw-r--r--src/e_pipes_next.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/e_pipes_next.c b/src/e_pipes_next.c
index 90e64f9..b39df15 100644
--- a/src/e_pipes_next.c
+++ b/src/e_pipes_next.c
@@ -37,9 +37,16 @@ static void e_fullpath_not_found(t_com *ptr, t_msh *msh)
exit(127);
}
-/*
-** TODO: handle execve failed
-*/
+static void e_execve_failed(const char fullpath[], t_com *ptr, t_msh *msh)
+{
+ f_exec(fullpath, ptr->bin);
+ u_eof_fd(msh->fd);
+ s_com_destroy(&msh->com);
+ s_lpipes_clear(&msh->pipes);
+ s_line_clear(&msh->curr);
+ s_destroy(msh);
+ exit(errno);
+}
void e_pipe_child(char fullpath[], uint8_t fp_ret, t_com *ptr, t_msh *msh)
{
@@ -62,16 +69,8 @@ void e_pipe_child(char fullpath[], uint8_t fp_ret, t_com *ptr, t_msh *msh)
{
if (fp_ret == 2)
e_fullpath_not_found(ptr, msh);
- if (execve(fullpath, ptr->argv, msh->envp) == -1)
- {
- f_exec(fullpath, ptr->bin);
- u_eof_fd(msh->fd);
- s_com_destroy(&msh->com);
- s_lpipes_clear(&msh->pipes);
- s_line_clear(&msh->curr);
- s_destroy(msh);
- exit(errno);
- }
+ else if (execve(fullpath, ptr->argv, msh->envp) == -1)
+ e_execve_failed(fullpath, ptr, msh);
}
}