mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:57:35 +00:00
Kernel: Fix PID/TID confusion in send_signal
This fixes the issue of a specific type of unkillable processes.
This commit is contained in:
parent
bee08a4b9f
commit
083671ef2c
1 changed files with 14 additions and 3 deletions
|
@ -790,9 +790,20 @@ void Process::terminate_due_to_signal(u8 signal)
|
||||||
KResult Process::send_signal(u8 signal, Process* sender)
|
KResult Process::send_signal(u8 signal, Process* sender)
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
// FIXME: PID/TID BUG
|
Thread* receiver_thread;
|
||||||
if (auto* thread = Thread::from_tid(m_pid.value())) {
|
// Try to send it to the "obvious" main thread:
|
||||||
thread->send_signal(signal, sender);
|
receiver_thread = Thread::from_tid(m_pid.value());
|
||||||
|
// If the main thread has died, there may still be other threads:
|
||||||
|
if (!receiver_thread) {
|
||||||
|
// The first one should be good enough.
|
||||||
|
// Neither kill(2) nor kill(3) specify any selection precedure.
|
||||||
|
for_each_thread([&receiver_thread](Thread& thread) -> IterationDecision {
|
||||||
|
receiver_thread = &thread;
|
||||||
|
return IterationDecision::Break;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (receiver_thread) {
|
||||||
|
receiver_thread->send_signal(signal, sender);
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
return KResult(-ESRCH);
|
return KResult(-ESRCH);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue