summaryrefslogtreecommitdiffstats
path: root/lib/libkse/thread/thr_join.c
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>1998-04-03 09:31:15 +0000
committerjb <jb@FreeBSD.org>1998-04-03 09:31:15 +0000
commit6a1d5a165901cbf6b76376a6c35d2306b55a2f72 (patch)
tree1c3148ba26408447be3c48a1afe9b17da5335d40 /lib/libkse/thread/thr_join.c
parenta6ff3fe2e91fc381861cc7c8409c5d66ba9cdf6c (diff)
downloadFreeBSD-src-6a1d5a165901cbf6b76376a6c35d2306b55a2f72.zip
FreeBSD-src-6a1d5a165901cbf6b76376a6c35d2306b55a2f72.tar.gz
Add a magic field to the pthread structure to help recognize valid
threads from invalid ones. The pthread structure is opaque to the user so this change does not cause any incompatibilities. Hopefully this change will help code that was written for draft 4 fail gracefully if the programmer ignores the compiler warning about the change in the level of indirection for the argument passed to pthread_detach(). I got burnt, so I fixed then (expletive deleted) thing. These functions comply with the revised standard. That should shut Terry up!
Diffstat (limited to 'lib/libkse/thread/thr_join.c')
-rw-r--r--lib/libkse/thread/thr_join.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/libkse/thread/thr_join.c b/lib/libkse/thread/thr_join.c
index 63d0d58..9e86a01 100644
--- a/lib/libkse/thread/thr_join.c
+++ b/lib/libkse/thread/thr_join.c
@@ -42,6 +42,16 @@ pthread_join(pthread_t pthread, void **thread_return)
int status;
pthread_t pthread1;
+ /* Check if the caller has specified an invalid thread: */
+ if (pthread == NULL || pthread->magic != PTHREAD_MAGIC)
+ /* Invalid thread: */
+ return(EINVAL);
+
+ /* Check if the caller has specified itself: */
+ if (pthread == _thread_run)
+ /* Avoid a deadlock condition: */
+ return(EDEADLK);
+
/* Block signals: */
_thread_kern_sig_block(&status);
OpenPOWER on IntegriCloud