From d34bd9a45440be2ef65d24619af5505b8c05c229 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 21 Sep 2021 17:26:36 +0200 Subject: make await() fail gracefully when callee has no alive children already --- src/init/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/init') diff --git a/src/init/main.c b/src/init/main.c index 558fb77..8e78b87 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -80,16 +80,17 @@ void fs_test(void) { void test_await(void) { char buf[16]; int len; + // the child immediately dies if (!_syscall_fork()) _syscall_exit(argify("i'm dead")); + if (!_syscall_fork()) + _syscall_exit(argify("i'm also dead")); - len = _syscall_await(buf, 16); - if (len < 0) { - log("await: negative len\n"); - } else { + while ((len = _syscall_await(buf, 16)) >= 0) { log("await returned: "); _syscall_write(tty_fd, buf, len, 0); log("\n"); } + log("await: negative len\n"); } -- cgit v1.2.3