From ad204c1d96ff23ab2421b8890d984fe5d78f690b Mon Sep 17 00:00:00 2001 From: bje Date: Thu, 23 Jul 1998 15:51:20 +0000 Subject: 1998-07-24 Ben Elliston * sync.c (pthread_join): Return if the target thread is detached. --- sync.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sync.c') diff --git a/sync.c b/sync.c index 5321da0..20009ac 100644 --- a/sync.c +++ b/sync.c @@ -12,6 +12,8 @@ int pthread_join(pthread_t thread, void ** valueptr) { LPDWORD exitcode; + _pthread_threads_thread_t * target; + pthread_t us = pthread_self(); /* First check if we are trying to join to ourselves. */ @@ -20,6 +22,18 @@ pthread_join(pthread_t thread, void ** valueptr) return EDEADLK; } + /* If the thread is detached, then join will return immediately. */ + + target = _pthread_find_thread_entry(thread); + if (target < 0) + { + return EINVAL; + } + else if (target->detached == PTHREAD_CREATE_DETACHED) + { + return ESRCH; + } + /* Wait on the kernel thread object. */ switch (WaitForSingleObject(thread, INFINITE)) { -- cgit v1.2.3