diff --git a/src/builtins/builtins.c b/src/builtins/builtins.c index b11b6e2..3fc2e9e 100644 --- a/src/builtins/builtins.c +++ b/src/builtins/builtins.c @@ -45,6 +45,8 @@ int run_builtin_parent(t_shell *shell, t_builtin builtin, t_cmd *cmd) dup2(saved_in, STDIN_FILENO); close(saved_in); close(saved_out); + if (shell->is_exitting) + (close(0), close(1)); return (code); } diff --git a/src/executor/executor.c b/src/executor/executor.c index ed15603..ab02bc6 100644 --- a/src/executor/executor.c +++ b/src/executor/executor.c @@ -48,7 +48,7 @@ static int malloc_pids(t_shell *shell) return (1); } -static int run_heredoc(t_shell *shell ) +static int run_heredoc(t_shell *shell) { set_signal_mode(HEREDOC); if (exec_heredoc(shell, getpid())) @@ -79,10 +79,8 @@ void executor(t_shell *shell) set_signal_mode(EXECUTION); builtin = get_builtin(current->cmd_args[0]); if (builtin != NULL && shell->cmd_count == 1) - { - shell->exit_status = run_builtin_parent(shell, builtin, shell->cmds); - return (shell->exit_status = 1, free(shell->pids)); - } + return (shell->exit_status = run_builtin_parent(shell, builtin, + shell->cmds), free(shell->pids)); if (!exec_loop(shell, fd, current)) return (free(shell->pids)); wait_pid(shell, shell->pids, shell->cmd_count);