summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sync.c14
1 files changed, 14 insertions, 0 deletions
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))
{