From 62afe606a355581c5b48cca361478c43fb6ae4cf Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 19 Apr 2020 22:27:11 +0200 Subject: Well well well that wasn't too bad, now remake everything --- src/ft_exec.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/ft_exec.c') diff --git a/src/ft_exec.c b/src/ft_exec.c index 555be96..408697d 100644 --- a/src/ft_exec.c +++ b/src/ft_exec.c @@ -12,6 +12,7 @@ /* ************************************************************************** */ #include +#include #include #include @@ -23,13 +24,16 @@ ft_exec(char **com) i = 0; while (com[i]) i++; - if (!ft_strncmp(com[0], "./", 2)) + if (fork() == 0) { - if ((execve(com[0] + 2, com, NULL)) != 0) - return (ft_error(com[0], 127)); + if (!ft_strncmp(com[0], "./", 2)) + { + if ((execve(com[0] + 2, com, NULL)) != 0) + return (ft_error(com[0], 127)); + } + else + if ((execve(com[0], com, NULL)) != 0) + return (ft_error(com[0], 127)); } - else - if ((execve(com[0], com, NULL)) != 0) - return (ft_error(com[0], 127)); return (0); } -- cgit v1.2.3