Kernel: Fix signal generation

We need to have interrupts enabled when signal kills the process as
process does mutex locking. Also signals are now only checked when
returning to userspace in the same place where userspace segments are
loaded.
This commit is contained in:
2026-04-04 22:36:54 +03:00
parent 47d85eb281
commit a29681a524
7 changed files with 166 additions and 143 deletions

View File

@@ -303,6 +303,8 @@ namespace Kernel
void Process::exit(int status, int signal)
{
ASSERT(Processor::get_interrupt_state() == InterruptState::Enabled);
bool expected = false;
if (!m_is_exiting.compare_exchange(expected, true))
{
@@ -310,9 +312,6 @@ namespace Kernel
ASSERT_NOT_REACHED();
}
const auto state = Processor::get_interrupt_state();
Processor::set_interrupt_state(InterruptState::Enabled);
if (m_parent)
{
Process* parent_process = nullptr;
@@ -369,8 +368,6 @@ namespace Kernel
while (m_threads.size() > 1)
Processor::yield();
Processor::set_interrupt_state(state);
Thread::current().on_exit();
ASSERT_NOT_REACHED();
@@ -2951,7 +2948,7 @@ namespace Kernel
for (;;)
{
while (Thread::current().will_exit_because_of_signal())
Thread::current().handle_signal();
Thread::current().handle_signal_if_interrupted();
SpinLockGuard guard(m_signal_lock);
if (!m_stopped)