Kernel: Send SIGCHLD to the parent process when changing stopped state
This is done also by linux (signal.c:936 in v5.11) at least. It's a pretty handy notification that allows the parent process to skip going through a `waitpid` and guesswork to figure out the current state of a child process.
This commit is contained in:
parent
47080941cc
commit
e3fd914187
Notes:
sideshowbarker
2024-07-18 20:56:08 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/e3fd914187b Pull-request: https://github.com/SerenityOS/serenity/pull/6021
1 changed files with 8 additions and 0 deletions
|
@ -911,6 +911,10 @@ void Thread::set_state(State new_state, u8 stop_signal)
|
|||
return IterationDecision::Continue;
|
||||
});
|
||||
process.unblock_waiters(Thread::WaitBlocker::UnblockFlags::Continued);
|
||||
// Tell the parent process (if any) about this change.
|
||||
if (auto parent = Process::from_pid(process.ppid())) {
|
||||
[[maybe_unused]] auto result = parent->send_signal(SIGCHLD, &process);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -930,6 +934,10 @@ void Thread::set_state(State new_state, u8 stop_signal)
|
|||
return IterationDecision::Continue;
|
||||
});
|
||||
process.unblock_waiters(Thread::WaitBlocker::UnblockFlags::Stopped, stop_signal);
|
||||
// Tell the parent process (if any) about this change.
|
||||
if (auto parent = Process::from_pid(process.ppid())) {
|
||||
[[maybe_unused]] auto result = parent->send_signal(SIGCHLD, &process);
|
||||
}
|
||||
}
|
||||
} else if (m_state == Dying) {
|
||||
VERIFY(previous_state != Blocked);
|
||||
|
|
Loading…
Add table
Reference in a new issue