fix errorstatus

This commit is contained in:
mcolonna 2024-06-28 16:09:43 +02:00
parent 3007dc9980
commit 3986c27e1c

View file

@ -6,7 +6,7 @@
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}