summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordzwdz2022-05-15 14:33:08 +0200
committerdzwdz2022-05-15 14:33:08 +0200
commitb35813737665afbbab0c226a2e6b1cb7406d4d40 (patch)
tree585b514e99a779d34760025deed529d797c28cf0
parent08ad0c42b4a50d142121a5eec2fcd5195c24998c (diff)
syscall/await: ensure the children are reapable before hanging
-rw-r--r--src/kernel/syscalls.c12
1 files 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) {