diff --git a/srcs/exec/subshell_wait.c b/srcs/exec/subshell_wait.c index fdf16b0..359d720 100644 --- a/srcs/exec/subshell_wait.c +++ b/srcs/exec/subshell_wait.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/16 01:57:38 by lperrey #+# #+# */ -/* Updated: 2021/11/18 13:27:43 by lperrey ### ########.fr */ +/* Updated: 2021/11/18 14:29:31 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,6 +26,11 @@ void wait_subshell(pid_t last_cmd_pid, int *last_exit_status) perror("waitpid()"); if (WIFEXITED(wstatus)) *last_exit_status = WEXITSTATUS(wstatus); + if (WIFSIGNALED(wstatus)) + { + write(STDIN_FILENO, "\n", 1); + *last_exit_status = 128 + WTERMSIG(wstatus); + } } ret = 0; while (ret != -1) @@ -34,11 +39,6 @@ void wait_subshell(pid_t last_cmd_pid, int *last_exit_status) if (ret == -1) ret = handle_wait_error(); } - if (WIFSIGNALED(wstatus)) - { - write(STDIN_FILENO, "\n", 1); - *last_exit_status = 128 + WTERMSIG(wstatus); - } } static int handle_wait_error(void)