From b35813737665afbbab0c226a2e6b1cb7406d4d40 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 15 May 2022 14:33:08 +0200 Subject: syscall/await: ensure the children are reapable before hanging --- src/kernel/syscalls.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 8636a1b..35b243f 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -23,15 +23,13 @@ int _syscall_await(void) { bool has_children = false; process_transition(process_current, PS_WAITS4CHILDDEATH); - // find any already dead children for (struct process *iter = process_current->child; - iter; iter = iter->sibling) { - if (iter->state == PS_DEAD && !iter->noreap) { - assert(!iter->noreap); + iter; iter = iter->sibling) + { + if (iter->noreap) continue; + has_children = true; + if (iter->state == PS_DEAD) SYSCALL_RETURN(process_try2collect(iter)); - } else { - has_children = true; - } } if (!has_children) { -- cgit v1.2.3