diff options
author | julian <julian@FreeBSD.org> | 1997-02-05 23:26:09 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1997-02-05 23:26:09 +0000 |
commit | c2f7c3e4893b6b5c4494d549b3645e06664bc1b1 (patch) | |
tree | b2e6d3017e236268263978b585f2150cd10b1689 /lib/libkse/thread/thr_join.c | |
parent | 321f03c8eddd8cf5aa81836ff1932a74156d30cb (diff) | |
download | FreeBSD-src-c2f7c3e4893b6b5c4494d549b3645e06664bc1b1.zip FreeBSD-src-c2f7c3e4893b6b5c4494d549b3645e06664bc1b1.tar.gz |
Submitted by: John Birrell
uthreads update from the author.
Diffstat (limited to 'lib/libkse/thread/thr_join.c')
-rw-r--r-- | lib/libkse/thread/thr_join.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/libkse/thread/thr_join.c b/lib/libkse/thread/thr_join.c index d0093ae..161482e 100644 --- a/lib/libkse/thread/thr_join.c +++ b/lib/libkse/thread/thr_join.c @@ -40,14 +40,40 @@ pthread_join(pthread_t pthread, void **thread_return) { int rval = 0; int status; + pthread_t pthread1; /* Block signals: */ _thread_kern_sig_block(&status); + /* Point to the first thread in the list: */ + pthread1 = _thread_link_list; + + /* Search for the thread to join to: */ + while (pthread1 != NULL && pthread1 != pthread) { + /* Point to the next thread: */ + pthread1 = pthread1->nxt; + } + + if (pthread1 == NULL) { + /* Point to the first thread in the dead thread list: */ + pthread1 = _thread_dead; + + /* Search for the thread to join to: */ + while (pthread1 != NULL && pthread1 != pthread) { + /* Point to the next thread: */ + pthread1 = pthread1->nxt; + } + } + + if (pthread1 == NULL) { + /* Return an error: */ + errno = ESRCH; + rval = -1; + /* Check if this thread has been detached: */ - if ((pthread->attr.flags & PTHREAD_DETACHED) != 0) { + } else if ((pthread->attr.flags & PTHREAD_DETACHED) != 0) { /* Return an error: */ - _thread_seterrno(_thread_run, ESRCH); + errno = ESRCH; rval = -1; } /* Check if the thread is not dead: */ @@ -70,7 +96,7 @@ pthread_join(pthread_t pthread, void **thread_return) } } else { /* Return an error: */ - _thread_seterrno(_thread_run, ESRCH); + errno = ESRCH; rval = -1; } } else { |