summaryrefslogtreecommitdiff
path: root/pthread_join.c
diff options
context:
space:
mode:
authorrpj <rpj>2003-08-14 08:53:17 +0000
committerrpj <rpj>2003-08-14 08:53:17 +0000
commita50745ec922a917513029f3f87bf820827b43f29 (patch)
tree1e221862e0550d163baef12d17634430ae677824 /pthread_join.c
parent414f4bd7e70d94025576d9264c86da63c506f6ca (diff)
Reuse of thread IDs, improved thread ID validation, new tests, bug fixes.
Diffstat (limited to 'pthread_join.c')
-rw-r--r--pthread_join.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/pthread_join.c b/pthread_join.c
index 3c076e0..1c5663c 100644
--- a/pthread_join.c
+++ b/pthread_join.c
@@ -38,6 +38,12 @@
#include "pthread.h"
#include "implement.h"
+/*
+ * Not needed yet, but defining it should indicate clashes with build target
+ * environment that should be fixed.
+ */
+#include <signal.h>
+
int
pthread_join (pthread_t thread, void **value_ptr)
@@ -74,20 +80,27 @@ pthread_join (pthread_t thread, void **value_ptr)
* ------------------------------------------------------
*/
{
- int result = 0;
+ int result;
pthread_t self;
+ /* This is the proper way to test for a valid thread ID */
+ result = pthread_kill(thread, 0);
+ if (0 != result)
+ {
+ return result;
+ }
+
self = pthread_self ();
- if (self == NULL)
+ if (NULL == self)
{
return ENOENT;
}
- if (pthread_equal (self, thread) != 0)
+ if (0 != pthread_equal (self, thread))
{
result = EDEADLK;
}
- else if (thread->detachState == PTHREAD_CREATE_DETACHED)
+ else if (PTHREAD_CREATE_DETACHED == thread->detachState)
{
result = EINVAL;
}