summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--sync.c29
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 <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>.
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)
/* </JEB> */
+
+