From 7761a8a41fe2b9b4906024a093a40ef0d54936bf Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 4 Dec 2024 22:44:16 +0100 Subject: [PATCH] kernel+launch: Always send SIGCHLD when a child exits POSIX says so. I thought it was only when the parent wasn't actively waiting, to signal it, but it turns out it's always sent. --- gui/launch.cpp | 2 +- kernel/src/thread/Thread.cpp | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/gui/launch.cpp b/gui/launch.cpp index 981b3222..6dca6415 100644 --- a/gui/launch.cpp +++ b/gui/launch.cpp @@ -48,7 +48,7 @@ void handle_ipc_message(os::IPC::ClientConnection& client, u8 id, void*) void sigchld_handler(int) { - os::Process::wait(os::Process::ANY_CHILD, nullptr); + os::Process::wait(os::Process::ANY_CHILD, nullptr, WNOHANG); } Result luna_main(int argc, char** argv) diff --git a/kernel/src/thread/Thread.cpp b/kernel/src/thread/Thread.cpp index 1d56b822..6909739c 100644 --- a/kernel/src/thread/Thread.cpp +++ b/kernel/src/thread/Thread.cpp @@ -147,11 +147,8 @@ Result> Thread::resolve_atfile(int dirfd, const String& pa parent->wake_up(); } } - else - { - while (parent->pending_signals.get(SIGCHLD - 1)) kernel_yield(); - parent->send_signal(SIGCHLD); - } + while (parent->pending_signals.get(SIGCHLD - 1)) kernel_yield(); + parent->send_signal(SIGCHLD); } state = ThreadState::Exited;