Kernel: Sending a signal to a process now goes to the main thread

Instead of falling back to the suspicious "any_thread()" mechanism,
just fail with ESRCH if you try to kill() a PID that doesn't have a
corresponding TID.
This commit is contained in:
Andreas Kling 2020-05-16 12:33:48 +02:00
parent c9e38c5255
commit 0e7f85c24a
Notes: sideshowbarker 2024-07-19 06:36:42 +09:00
2 changed files with 8 additions and 9 deletions

View file

@ -2179,7 +2179,7 @@ KResult Process::do_kill(Process& process, int signal)
return KResult(-EPERM);
}
if (signal != 0)
process.send_signal(signal, this);
return process.send_signal(signal, this);
return KSuccess;
}
@ -3781,15 +3781,14 @@ void Process::terminate_due_to_signal(u8 signal)
die();
}
void Process::send_signal(u8 signal, Process* sender)
KResult Process::send_signal(u8 signal, Process* sender)
{
InterruptDisabler disabler;
if (!m_thread_count)
return;
auto* thread = Thread::from_tid(m_pid);
if (!thread)
thread = &any_thread();
thread->send_signal(signal, sender);
if (auto* thread = Thread::from_tid(m_pid)) {
thread->send_signal(signal, sender);
return KSuccess;
}
return KResult(-ESRCH);
}
int Process::sys$create_thread(void* (*entry)(void*), const Syscall::SC_create_thread_params* user_params)