From a121299c2ad417b238b7c20d30f4cf064e3700fd Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 11 Feb 2023 14:45:06 +0100 Subject: wait for children after line --- smash/exec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/smash/exec.c b/smash/exec.c index 0fca393..b37576a 100644 --- a/smash/exec.c +++ b/smash/exec.c @@ -11,6 +11,7 @@ #include "../lib/io/io.h" #include "../lib/env/env.h" #include "../lib/malloc/malloc.h" +#include "../lib/list/list.h" #include "parser.h" #include "builtin.h" @@ -61,6 +62,7 @@ void exec(char *line) { expression_list_t *exps = new_expression_from_line(line); expression_list_t *exp = exps; + list_t *pids = new_list(); int pid; int pipefd[2][2]; @@ -106,10 +108,16 @@ void exec(char *line) free_argv(argv); - wait4(pid, 0, 0); + list_append(pids, pid); exp = exp->next; } + list_node_t *node = pids->first; + + for (; node; node = node->next) { + wait4((int)node->value, 0, 0); + } + free_expression(exps); } -- cgit v1.2.3-70-g09d2