mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00
Kernel: Move signal handlers from being thread state to process state
POSIX requires that sigaction() and friends set a _process-wide_ signal handler, so move signal handlers and flags inside Process. This also fixes a "pid/tid confusion" FIXME, as we can now send the signal to the process and let that decide which thread should get the signal (which is the thread with tid==pid, but that's now the Process's problem). Note that each thread still retains its signal mask, as that is local to each thread.
This commit is contained in:
parent
18b9d02edd
commit
cf63447044
5 changed files with 19 additions and 19 deletions
|
@ -58,15 +58,17 @@ ErrorOr<FlatPtr> Process::sys$sigaction(int signum, Userspace<const sigaction*>
|
|||
return EINVAL;
|
||||
|
||||
InterruptDisabler disabler; // FIXME: This should use a narrower lock. Maybe a way to ignore signals temporarily?
|
||||
auto& action = Thread::current()->m_signal_action_data[signum];
|
||||
auto& action = m_signal_action_data[signum];
|
||||
if (user_old_act) {
|
||||
sigaction old_act {};
|
||||
old_act.sa_flags = action.flags;
|
||||
old_act.sa_sigaction = reinterpret_cast<decltype(old_act.sa_sigaction)>(action.handler_or_sigaction.as_ptr());
|
||||
old_act.sa_mask = action.mask;
|
||||
TRY(copy_to_user(user_old_act, &old_act));
|
||||
}
|
||||
if (user_act) {
|
||||
auto act = TRY(copy_typed_from_user(user_act));
|
||||
action.mask = act.sa_mask;
|
||||
action.flags = act.sa_flags;
|
||||
action.handler_or_sigaction = VirtualAddress { reinterpret_cast<void*>(act.sa_sigaction) };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue