Fix pthread_detach for already-exited threads.
Change-Id: I2bf7f41234d93b226132a4c51705f4186f4961c3 Reported-by: Paresh Nakhe <pnakhe@codeaurora.org>
This commit is contained in:
@@ -44,6 +44,12 @@ int pthread_detach(pthread_t t) {
|
||||
return 0; // Already being joined; silently do nothing, like glibc.
|
||||
}
|
||||
|
||||
if (thread->tid == 0) {
|
||||
// Already exited; clean up.
|
||||
_pthread_internal_remove_locked(thread.get());
|
||||
return 0;
|
||||
}
|
||||
|
||||
thread->attr.flags |= PTHREAD_ATTR_FLAG_DETACHED;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user