From c9396be83f67edfbd07a5cd7a5b34e6be7aa81ac Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 28 Mar 2020 11:03:43 +0300 Subject: [PATCH] WaitBlocker: don't unblock if thread has pending SIGCONT Previosuly, if we sent a SIGCONT to a stopped thread and then waitpid() with WSTOPPED on that thread before the signal was dispatched, then the WaitBlocker would first unblock (because the thread is stopped) and only after that the thread would get the SIGCONT signal. This would mean that when waitpid returns the waitee is not stopped. To fix this, we do not unblock the waiting thread if the waitee thread has a pending SIGCONT. --- Kernel/Scheduler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index a5e23c790b0..163705025d2 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -261,7 +261,12 @@ bool Thread::WaitBlocker::should_unblock(Thread& thread, time_t, long) return IterationDecision::Continue; bool child_exited = child.is_dead(); - bool child_stopped = child.thread_count() && child.any_thread().state() == Thread::State::Stopped; + bool child_stopped = false; + if (child.thread_count()) { + auto& child_thread = child.any_thread(); + if (child_thread.state() == Thread::State::Stopped && !child_thread.has_pending_signal(SIGCONT)) + child_stopped = true; + } bool wait_finished = ((m_wait_options & WEXITED) && child_exited) || ((m_wait_options & WSTOPPED) && child_stopped);