1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-18 15:30:21 +00:00

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.
This commit is contained in:
Mike Makonnen 2004-03-29 13:51:51 +00:00
parent 2c08d6bea1
commit 8c223652fb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127568

View File

@ -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;