diff --git a/include/execution.h b/include/execution.h index 47e665c..451153b 100644 --- a/include/execution.h +++ b/include/execution.h @@ -6,7 +6,7 @@ /* By: mmoussou infile, STDIN_FILENO); if (cmd->infile != STDIN_FILENO) close(cmd->infile); @@ -58,7 +60,15 @@ void __fork_single_cmd(t_cmd *cmd, char **env, t_env *env_t, t_exec exec) if (exec.pipe_fd[0] != -1) close(exec.pipe_fd[1]); if (exec.status != -1) + { + i = 3; + while (i < 1024) + { + close(i); + i++; + } exec_cmd(cmd, env, env_t); + } } int exec_single_cmd_execution(t_cmd *cmd, char **env, t_env *env_t, t_exec exec) diff --git a/src/exec/exec_split_cmd.c b/src/exec/exec_split_cmd.c index 46c2ae8..86ce4b6 100644 --- a/src/exec/exec_split_cmd.c +++ b/src/exec/exec_split_cmd.c @@ -6,7 +6,7 @@ /* By: mmoussou cmd) - return (get_exit_code(0)); + return (close_cmd(cmd)); ft_arrcpy(exec.pipe_fd, pipe_fd, 2); input = ft_strdup(cmd->cmd); exec.status = switch_cmd_path(cmd, env_t); @@ -54,8 +54,7 @@ int exec_single_cmd(t_cmd *cmd, char **env, t_env *env_t, int pipe_fd[2]) if (!cmd->cmd) { - if (cmd->argv) - ft_free("a", &(cmd->argv)); + free_cmd(cmd); rl_clear_history(); get_exit_code(0); return (0); diff --git a/src/exec/utils_exec_2.c b/src/exec/utils_exec_2.c index b7c1069..49d3220 100644 --- a/src/exec/utils_exec_2.c +++ b/src/exec/utils_exec_2.c @@ -6,7 +6,7 @@ /* By: mmoussou infile != STDIN_FILENO) + close(cmd->infile); + if (cmd->outfile != STDOUT_FILENO) + close(cmd->outfile); + return (get_exit_code(0)); +}