mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:27:42 +00:00
Kernel+LibPthread: Implement pthread_detach()
This commit is contained in:
parent
9ddfe694f2
commit
95b086f47f
4 changed files with 29 additions and 1 deletions
|
@ -2915,6 +2915,27 @@ void Process::sys$exit_thread(void* exit_value)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
int Process::sys$detach_thread(int tid)
|
||||
{
|
||||
Thread* thread = nullptr;
|
||||
for_each_thread([&](auto& child_thread) {
|
||||
if (child_thread.tid() == tid) {
|
||||
thread = &child_thread;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
if (!thread)
|
||||
return -ESRCH;
|
||||
|
||||
if (!thread->is_joinable())
|
||||
return -EINVAL;
|
||||
|
||||
thread->set_joinable(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$join_thread(int tid, void** exit_value)
|
||||
{
|
||||
if (exit_value && !validate_write_typed(exit_value))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue