From 3a85b1a195bf88cea7ffd405a18a24a854ffeba7 Mon Sep 17 00:00:00 2001 From: mcolonna Date: Fri, 26 Apr 2024 14:23:37 +0200 Subject: [PATCH] [FIX] wait all programs to end before prompting --- include/include.h | 3 ++- src/exec_command.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/include.h b/include/include.h index c17a69f..47104c6 100644 --- a/include/include.h +++ b/include/include.h @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */ -/* Updated: 2024/04/26 12:33:20 by mcolonna ### ########.fr */ +/* Updated: 2024/04/26 14:21:43 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,6 +22,7 @@ # include # include # include +# include # include "libft.h" # include "libtf.h" diff --git a/src/exec_command.c b/src/exec_command.c index 50c83ca..7a28b44 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/04/26 12:31:49 by mcolonna ### ########.fr */ +/* Updated: 2024/04/26 14:21:15 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -58,6 +58,15 @@ static int execute_call(t_memclass mc, t_call call, const int inout[2], int execute_command(t_memclass mc, t_command command, char *const envp[]) { const int inout[] = {0, 1}; + int nb_calls; + int r; - return (execute_call(mc, command.calls[0], inout, envp)); + nb_calls = 1; + r = execute_call(mc, command.calls[0], inout, envp); + while (nb_calls) + { + wait(NULL); + nb_calls--; + } + return (r); }