summaryrefslogtreecommitdiff
path: root/sync.c
diff options
context:
space:
mode:
authorbje <bje>1998-07-23 15:51:20 +0000
committerbje <bje>1998-07-23 15:51:20 +0000
commitad204c1d96ff23ab2421b8890d984fe5d78f690b (patch)
treef11212e7adc1be40e1ff0992dcef91d105dfc673 /sync.c
parent77116f1ab96c37848c06f23188fea4009be92ae3 (diff)
1998-07-24 Ben Elliston <bje@cygnus.com>
* sync.c (pthread_join): Return if the target thread is detached.
Diffstat (limited to 'sync.c')
-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))
{