summaryrefslogtreecommitdiffstats
path: root/src/e_pipes_next.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-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);
}
}