Kernel: Expose the signal that stopped a thread via sys$waitpid()

This commit is contained in:
Andreas Kling 2020-01-27 20:47:10 +01:00
parent 638fe6f84a
commit 5163c5cc63
3 changed files with 11 additions and 2 deletions

View file

@ -2318,12 +2318,16 @@ pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
if (!waitee_process)
return -ECHILD;
auto* waitee_thread = Thread::from_tid(waitee_pid);
if (!waitee_thread)
return -ECHILD;
ASSERT(waitee_process);
if (waitee_process->is_dead()) {
exit_status = reap(*waitee_process);
} else {
ASSERT(waitee_process->any_thread().state() == Thread::State::Stopped);
exit_status = 0x7f;
ASSERT(waitee_thread->state() == Thread::State::Stopped);
exit_status = (waitee_thread->m_stop_signal << 8) | 0x7f;
}
if (wstatus)

View file

@ -471,6 +471,7 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
m_pending_signals &= ~(1 << (signal - 1));
if (signal == SIGSTOP) {
m_stop_signal = SIGSTOP;
set_state(Stopped);
return ShouldUnblockThread::No;
}
@ -482,6 +483,7 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
if (handler_vaddr.is_null()) {
switch (default_signal_action(signal)) {
case DefaultSignalAction::Stop:
m_stop_signal = signal;
set_state(Stopped);
return ShouldUnblockThread::No;
case DefaultSignalAction::DumpCore:

View file

@ -485,6 +485,9 @@ private:
u32 m_priority { THREAD_PRIORITY_NORMAL };
u32 m_extra_priority { 0 };
u32 m_priority_boost { 0 };
u8 m_stop_signal { 0 };
bool m_dump_backtrace_on_finalization { false };
bool m_should_die { false };