Make some fixups to POSIX threads

This commit is contained in:
Justine Tunney 2022-09-07 21:13:50 -07:00
parent de511bc71a
commit 6c323383e5
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
12 changed files with 168 additions and 69 deletions

View file

@ -32,14 +32,15 @@
*/
int pthread_join(pthread_t thread, void **value_ptr) {
struct PosixThread *pt = thread;
if (pt->status == kPosixThreadDetached) {
if (pt->status == kPosixThreadDetached || //
pt->status == kPosixThreadZombie) {
assert(!"badjoin");
return EDEADLK;
}
pthread_wait(pt);
_pthread_wait(pt);
if (value_ptr) {
*value_ptr = pt->rc;
}
pthread_free(pt);
_pthread_free(pt);
return 0;
}