1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:47:45 +00:00

Kernel: Restore the previous thread state on SIGCONT after SIGSTOP

When stopping a thread with the SIGSTOP signal, we now store the thread
state in Thread::m_stop_state. That state is then restored on SIGCONT.
This fixes an issue where previously-blocked threads would unblock
upon resume. Now they simply resume in the Blocked state, and it's up
to the regular unblocking mechanism to unblock them.

Fixes #1326.
This commit is contained in:
Andreas Kling 2020-03-01 15:14:17 +01:00
parent fbe9aad70a
commit 2839bb0be1
2 changed files with 11 additions and 4 deletions

View file

@ -495,13 +495,19 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
m_pending_signals &= ~(1 << (signal - 1)); m_pending_signals &= ~(1 << (signal - 1));
if (signal == SIGSTOP) { if (signal == SIGSTOP) {
m_stop_signal = SIGSTOP; if (!is_stopped()) {
set_state(Stopped); m_stop_signal = SIGSTOP;
m_stop_state = m_state;
set_state(State::Stopped);
}
return ShouldUnblockThread::No; return ShouldUnblockThread::No;
} }
if (signal == SIGCONT && state() == Stopped) if (signal == SIGCONT && is_stopped()) {
set_state(Runnable); ASSERT(m_stop_state != State::Invalid);
set_state(m_stop_state);
m_stop_state = State::Invalid;
}
auto handler_vaddr = action.handler_or_sigaction; auto handler_vaddr = action.handler_or_sigaction;
if (handler_vaddr.is_null()) { if (handler_vaddr.is_null()) {

View file

@ -486,6 +486,7 @@ private:
u32 m_priority_boost { 0 }; u32 m_priority_boost { 0 };
u8 m_stop_signal { 0 }; u8 m_stop_signal { 0 };
State m_stop_state { Invalid };
bool m_dump_backtrace_on_finalization { false }; bool m_dump_backtrace_on_finalization { false };
bool m_should_die { false }; bool m_should_die { false };