summaryrefslogtreecommitdiffstats
path: root/src/e_pipes_next.c
diff options
context:
space:
mode:
authorjoe <rbousset@42lyon.fr>2020-12-01 16:12:02 +0100
committerjoe <rbousset@42lyon.fr>2020-12-01 16:12:02 +0100
commit214eae8a55bde34ca412084bebdb378a696152cc (patch)
tree70404f68b1b86035fe4835d8cf2da61dcefc5eba /src/e_pipes_next.c
parentNot quite done (diff)
download42-minishell-214eae8a55bde34ca412084bebdb378a696152cc.tar.gz
42-minishell-214eae8a55bde34ca412084bebdb378a696152cc.tar.bz2
42-minishell-214eae8a55bde34ca412084bebdb378a696152cc.tar.xz
42-minishell-214eae8a55bde34ca412084bebdb378a696152cc.tar.zst
42-minishell-214eae8a55bde34ca412084bebdb378a696152cc.zip
Bav
Diffstat (limited to 'src/e_pipes_next.c')
-rw-r--r--src/e_pipes_next.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/e_pipes_next.c b/src/e_pipes_next.c
index 93eb42e..a129f2e 100644
--- a/src/e_pipes_next.c
+++ b/src/e_pipes_next.c
@@ -40,30 +40,19 @@ static void e_fullpath_not_found(t_com *ptr, t_msh *msh)
static void e_exec_child(const char fullpath[], t_com *ptr, t_msh *msh)
{
- char buff[7];
- int fd;
-
- if ((fd = open(fullpath, O_RDONLY)) != -1)
- {
- if (read(fd, buff, 7) != -1)
- if (ft_strncmp(buff, "\177ELF\002\001\001", 7) != 0
- && ft_strncmp(buff, "#!", 2) != 0)
- {
- close(fd);
- e_extern_read_script(fullpath, ptr, msh, TRUE);
- return ;
- }
- close(fd);
- }
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);
+ if (errno != ENOEXEC)
+ {
+ 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);
+ }
+ e_extern_read_script(fullpath, ptr, msh, FALSE);
}
}