From 451c3f5cb2ce9934dba7ad6ba0976fe6ff85d829 Mon Sep 17 00:00:00 2001 From: ruipedro-pinheiro Date: Thu, 29 Oct 2026 12:38:20 +0100 Subject: [PATCH 1/3] fix where exit-status is overwritten after getting the correct code after each child --- src/executor/executor.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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); From ab0922d1bbee69bd18dcdc1c269bcb73ee498e1e Mon Sep 17 00:00:00 2001 From: ruipedro-pinheiro Date: Thu, 29 Oct 2026 13:20:33 +0100 Subject: [PATCH 2/3] fix open fd when shell quits quel shell quits there is 2 fs open, the stdin and the stdout. For the moment i am just checking if the bool (is_exitting) and if it's the case then i close those two fds but i must find how and why they are open before. --- src/builtins/builtins.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/builtins/builtins.c b/src/builtins/builtins.c index b11b6e2..3d2db0f 100644 --- a/src/builtins/builtins.c +++ b/src/builtins/builtins.c @@ -45,6 +45,11 @@ 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); } From bd379349bb7cf4086d88aa60f11a5412d27a9514 Mon Sep 17 00:00:00 2001 From: ruipedro-pinheiro Date: Thu, 29 Oct 2026 13:28:32 +0100 Subject: [PATCH 3/3] norm complying --- src/builtins/builtins.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/builtins/builtins.c b/src/builtins/builtins.c index 3d2db0f..3fc2e9e 100644 --- a/src/builtins/builtins.c +++ b/src/builtins/builtins.c @@ -46,10 +46,7 @@ int run_builtin_parent(t_shell *shell, t_builtin builtin, t_cmd *cmd) close(saved_in); close(saved_out); if (shell->is_exitting) - { - close(0); - close(1); - } + (close(0), close(1)); return (code); }