diff options
| author | Julian Elischer <julian@FreeBSD.org> | 1997-02-05 23:26:09 +0000 |
|---|---|---|
| committer | Julian Elischer <julian@FreeBSD.org> | 1997-02-05 23:26:09 +0000 |
| commit | c840cec7c5df4547d37d9ca025553099b834c1aa (patch) | |
| tree | b2e6d3017e236268263978b585f2150cd10b1689 /lib/libpthread/thread/thr_join.c | |
| parent | 3b576b3e5eac153732d10d222cc023a02adc3db7 (diff) | |
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_join.c')
| -rw-r--r-- | lib/libpthread/thread/thr_join.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/libpthread/thread/thr_join.c b/lib/libpthread/thread/thr_join.c index d0093ae72f05..161482e289a8 100644 --- a/lib/libpthread/thread/thr_join.c +++ b/lib/libpthread/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 { |
