Fix pthread_detach for already-exited threads.

Change-Id: I2bf7f41234d93b226132a4c51705f4186f4961c3
Reported-by: Paresh Nakhe <pnakhe@codeaurora.org>
This commit is contained in:
Elliott Hughes
2014-03-07 17:59:05 -08:00
parent 333e2ae87d
commit 04620a3cd7
2 changed files with 36 additions and 0 deletions

View File

@@ -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;
}