From 3986c27e1c5d55ba487a072907edadb273132d9d Mon Sep 17 00:00:00 2001 From: mcolonna Date: Fri, 28 Jun 2024 16:09:43 +0200 Subject: [PATCH] fix errorstatus --- src/exec_command.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/exec_command.c b/src/exec_command.c index 1c808b9..37e2d66 100644 --- a/src/exec_command.c +++ b/src/exec_command.c @@ -6,7 +6,7 @@ /* By: jschaft +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/24 13:48:00 by jschaft #+# #+# */ -/* Updated: 2024/06/28 14:04:08 by mcolonna ### ########.fr */ +/* Updated: 2024/06/28 16:08:02 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -113,6 +113,7 @@ int execute_command(t_env *env, t_command command) { t_exec_command_global global; int r; + int wstatus; r = 0; global.mc = env->mc_command; @@ -127,9 +128,11 @@ int execute_command(t_env *env, t_command command) return (r); r = exec_each_call(&global, command, env); close_all_pipes(&global); - while (wait(NULL) != -1) + while (wait(&wstatus) != -1) ; if (errno != ECHILD) return (minishell_error("errno"), errno); + if (!r) + r = WEXITSTATUS(wstatus); return (r); }