diff options
Diffstat (limited to 'lib/libkse/thread/thr_join.c')
-rw-r--r-- | lib/libkse/thread/thr_join.c | 10 |
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); |