kernel: Also move children's parent to PID 1 in the common thread exit function
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-06-19 12:35:31 +02:00
parent e60b2a3d2f
commit 54a1998d42
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 6 additions and 5 deletions

View File

@ -7,10 +7,5 @@ Result<u64> sys_exit(Registers*, SyscallArgs args)
Thread* current = Scheduler::current();
Scheduler::for_each_child(current, [](Thread* child) {
child->parent = Scheduler::init_thread();
return true;
});
current->exit_and_signal_parent(status);
}

View File

@ -74,6 +74,11 @@ Result<SharedPtr<VFS::Inode>> Thread::resolve_atfile(int dirfd, const String& pa
if (is_kernel) state = ThreadState::Dying;
else
{
Scheduler::for_each_child(this, [](Thread* child) {
child->parent = Scheduler::init_thread();
return true;
});
if (parent && parent->state == ThreadState::Waiting)
{
auto child = *parent->child_being_waited_for;
@ -83,6 +88,7 @@ Result<SharedPtr<VFS::Inode>> Thread::resolve_atfile(int dirfd, const String& pa
parent->wake_up();
}
}
state = ThreadState::Exited;
}
status = _status;