From 856068d292843ed7e8b3c49ecf55bd5f5c1b2368 Mon Sep 17 00:00:00 2001 From: rpj Date: Tue, 2 Feb 1999 15:16:42 +0000 Subject: Wed Feb 3 10:13:48 1999 Ross Johnson * sync.c (pthread_join): Check for NULL value_ptr arg; check for detached threads. --- ChangeLog | 5 +++++ sync.c | 29 ++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2615bc0..6155236 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Feb 3 10:13:48 1999 Ross Johnson + + * sync.c (pthread_join): Check for NULL value_ptr arg; + check for detached threads. + Tue Feb 2 18:07:43 1999 Ross Johnson * implement.h: Add #include . diff --git a/sync.c b/sync.c index 57f56b8..5b4ee9a 100644 --- a/sync.c +++ b/sync.c @@ -72,8 +72,11 @@ pthread_join (pthread_t thread, void **value_ptr) * completion. * * PARAMETERS - * sem - * pointer to an instance of sem_t + * thread + * an instance of pthread_t + * + * value_ptr + * pointer to an instance of pointer to void * * * DESCRIPTION @@ -100,7 +103,10 @@ pthread_join (pthread_t thread, void **value_ptr) if (pthread_equal (self, thread) == 0) { result = EDEADLK; - + } + else if (thread->detachState == PTHREAD_CREATE_DETACHED) + { + result = EINVAL; } else { @@ -108,14 +114,21 @@ pthread_join (pthread_t thread, void **value_ptr) stat = WaitForSingleObject (thread->threadH, INFINITE); - if (stat != WAIT_OBJECT_0 && - !GetExitCodeThread (thread->threadH, (LPDWORD) value_ptr)) + if (stat == WAIT_OBJECT_0) { - result = ESRCH; + if (value_ptr != NULL + && !GetExitCodeThread (thread->threadH, (LPDWORD) value_ptr)) + { + result = ESRCH; + } + else + { + _pthread_threadDestroy (thread); + } } else { - _pthread_threadDestroy (thread); + result = ESRCH; } } @@ -125,3 +138,5 @@ pthread_join (pthread_t thread, void **value_ptr) /* */ + + -- cgit v1.2.3