diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-19 22:27:11 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-19 22:27:11 +0200 |
commit | 62afe606a355581c5b48cca361478c43fb6ae4cf (patch) | |
tree | a278fe2fdf44c296892616554743b9d380ff7afa /src/ft_exec.c | |
parent | Added joe-sh_history to gitignore (diff) | |
download | 42-minishell-62afe606a355581c5b48cca361478c43fb6ae4cf.tar.gz 42-minishell-62afe606a355581c5b48cca361478c43fb6ae4cf.tar.bz2 42-minishell-62afe606a355581c5b48cca361478c43fb6ae4cf.tar.xz 42-minishell-62afe606a355581c5b48cca361478c43fb6ae4cf.tar.zst 42-minishell-62afe606a355581c5b48cca361478c43fb6ae4cf.zip |
Well well well that wasn't too bad, now remake everything
Diffstat (limited to '')
-rw-r--r-- | src/ft_exec.c | 16 |
1 files changed, 10 insertions, 6 deletions
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 <libft.h> +#include <stdlib.h> #include <minishell.h> #include <unistd.h> @@ -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); } |