diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | sync.c | 29 |
2 files changed, 27 insertions, 7 deletions
@@ -1,3 +1,8 @@ +Wed Feb 3 10:13:48 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> + + * sync.c (pthread_join): Check for NULL value_ptr arg; + check for detached threads. + Tue Feb 2 18:07:43 1999 Ross Johnson <rpj@swan.canberra.edu.au> * implement.h: Add #include <pthread.h>. @@ -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) /* </JEB> */ + + |