summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2004-03-29 13:51:51 +0000
committermtm <mtm@FreeBSD.org>2004-03-29 13:51:51 +0000
commit319c9db836accc9a96513774f6e27cc1722922a6 (patch)
treebfbaba814cce9c5b344c9743059e9558f8eab6a1 /lib/libthr
parentaf934bf9681a6b4759df87bbe342c063f2d9dc13 (diff)
downloadFreeBSD-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')
-rw-r--r--lib/libthr/thread/thr_detach.c6
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;
OpenPOWER on IntegriCloud