mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
Kernel: Expose the signal that stopped a thread via sys$waitpid()
This commit is contained in:
parent
638fe6f84a
commit
5163c5cc63
Notes:
sideshowbarker
2024-07-19 09:46:34 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5163c5cc63c
3 changed files with 11 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 };
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue