kernel: Wake the parent process when a child exits because of a page fault

This commit is contained in:
apio 2023-05-28 21:50:13 +02:00
parent 30e4ef970e
commit 11a4f8cc90
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -73,7 +73,22 @@ void decode_page_fault_error_code(u64 code)
{
// FIXME: Kill this process with SIGSEGV once we have signals and all that.
kerrorln("Current task %zu was terminated because of a page fault", Scheduler::current()->id);
Scheduler::current()->state = ThreadState::Exited;
if (Scheduler::current()->is_kernel) Scheduler::current()->state = ThreadState::Dying;
else
{
auto* current = Scheduler::current();
auto* parent = current->parent;
if (parent && parent->state == ThreadState::Waiting)
{
auto child = *parent->child_being_waited_for;
if (child == -1 || child == (pid_t)current->id)
{
parent->child_being_waited_for = (pid_t)current->id;
parent->wake_up();
}
}
current->state = ThreadState::Exited;
}
Scheduler::current()->status = 127;
kernel_yield();
unreachable();