diff options
author | mtm <mtm@FreeBSD.org> | 2004-03-29 13:51:51 +0000 |
---|---|---|
committer | mtm <mtm@FreeBSD.org> | 2004-03-29 13:51:51 +0000 |
commit | 319c9db836accc9a96513774f6e27cc1722922a6 (patch) | |
tree | bfbaba814cce9c5b344c9743059e9558f8eab6a1 /lib/libthr/thread/thr_detach.c | |
parent | af934bf9681a6b4759df87bbe342c063f2d9dc13 (diff) | |
download | FreeBSD-src-319c9db836accc9a96513774f6e27cc1722922a6.zip FreeBSD-src-319c9db836accc9a96513774f6e27cc1722922a6.tar.gz |
o If a thread is marked as detached AND on the dead threads list
the correct return value is ESRCH.
o Don't check the attribute for NULL. It's the caller's responsibility.
o Make the bitwise comparison explicit.
Diffstat (limited to 'lib/libthr/thread/thr_detach.c')
-rw-r--r-- | lib/libthr/thread/thr_detach.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libthr/thread/thr_detach.c b/lib/libthr/thread/thr_detach.c index a2ad4d4..7d87d05 100644 --- a/lib/libthr/thread/thr_detach.c +++ b/lib/libthr/thread/thr_detach.c @@ -41,14 +41,14 @@ __weak_reference(_pthread_detach, pthread_detach); int _pthread_detach(pthread_t pthread) { - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) + if (pthread->magic != PTHREAD_MAGIC) return (EINVAL); UMTX_LOCK(&pthread->lock); - if (pthread->attr.flags & PTHREAD_DETACHED) { + if ((pthread->attr.flags & PTHREAD_DETACHED) != 0) { UMTX_UNLOCK(&pthread->lock); - return (EINVAL); + return ((pthread->state == PS_DEAD) ? ESRCH : EINVAL); } pthread->attr.flags |= PTHREAD_DETACHED; |