diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 009b4baf8b..c609e36044 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -379,7 +379,7 @@ int Process::do_exec(const String& path, Vector&& arguments, Vector 0); // FIXME: Implement other PID specs. auto* waitee_process = Process::from_pid(waitee); if (!waitee_process) return -ECHILD; @@ -1825,6 +1830,13 @@ int Process::sys$sigpending(sigset_t* set) return 0; } +void Process::set_default_signal_dispositions() +{ + // FIXME: Set up all the right default actions. See signal(7). + memset(&m_signal_action_data, 0, sizeof(m_signal_action_data)); + m_signal_action_data[SIGCHLD].handler_or_sigaction = LinearAddress((dword)SIG_IGN); +} + int Process::sys$sigaction(int signum, const sigaction* act, sigaction* old_act) { if (signum < 1 || signum >= 32 || signum == SIGKILL || signum == SIGSTOP) diff --git a/Kernel/Process.h b/Kernel/Process.h index cd337184cb..ca4d68d689 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -31,6 +31,8 @@ struct CoolGlobals { extern CoolGlobals* g_cool_globals; #endif +enum class ShouldUnblockProcess { No = 0, Yes }; + struct SignalActionData { LinearAddress handler_or_sigaction; dword mask { 0 }; @@ -261,8 +263,9 @@ public: size_t max_open_file_descriptors() const { return m_max_open_file_descriptors; } void send_signal(byte signal, Process* sender); - bool dispatch_one_pending_signal(); - bool dispatch_signal(byte signal); + + ShouldUnblockProcess dispatch_one_pending_signal(); + ShouldUnblockProcess dispatch_signal(byte signal); bool has_unmasked_pending_signals() const; void terminate_due_to_signal(byte signal); @@ -296,6 +299,7 @@ private: void push_value_on_stack(dword); int alloc_fd(); + void set_default_signal_dispositions(); RetainPtr m_page_directory; diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index 62c0178619..c81ff99256 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -134,7 +134,7 @@ bool Scheduler::pick_next() return true; // NOTE: dispatch_one_pending_signal() may unblock the process. bool was_blocked = process.is_blocked(); - if (!process.dispatch_one_pending_signal()) + if (process.dispatch_one_pending_signal() == ShouldUnblockProcess::No) return true; if (was_blocked) { dbgprintf("Unblock %s(%u) due to signal\n", process.name().characters(), process.pid()); diff --git a/Userland/guitest2.cpp b/Userland/guitest2.cpp index 37693fac7f..64ca47966f 100644 --- a/Userland/guitest2.cpp +++ b/Userland/guitest2.cpp @@ -73,6 +73,9 @@ static GWindow* make_clock_window(); void handle_sigchld(int) { dbgprintf("Got SIGCHLD\n"); + int pid = waitpid(-1, nullptr, 0); + dbgprintf("waitpid() returned %d\n", pid); + ASSERT(pid > 0); } int main(int argc, char** argv)