diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-02-11 14:45:06 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-02-11 14:45:06 +0100 |
| commit | a121299c2ad417b238b7c20d30f4cf064e3700fd (patch) | |
| tree | 7bf712190be0e41d6f559d0a5e4a4ca2973eac55 /smash | |
| parent | 62d9c9d2429b6f382d46b6649612553d40ecf618 (diff) | |
wait for children after line
Diffstat (limited to 'smash')
| -rw-r--r-- | smash/exec.c | 10 |
1 files changed, 9 insertions, 1 deletions
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); } |