diff --git a/sched/pthread/pthread_completejoin.c b/sched/pthread/pthread_completejoin.c index 02dae59b187f9..f65ef9b85456b 100644 --- a/sched/pthread/pthread_completejoin.c +++ b/sched/pthread/pthread_completejoin.c @@ -188,11 +188,12 @@ static void pthread_removejoininfo(FAR struct task_group_s *group, int pthread_completejoin(pid_t pid, FAR void *exit_value) { - FAR struct task_group_s *group = task_getgroup(pid); + FAR struct tcb_s *tcb = nxsched_get_tcb(pid); + FAR struct task_group_s *group = tcb ? tcb->group : NULL; FAR struct join_s *pjoin; sinfo("pid=%d exit_value=%p group=%p\n", pid, exit_value, group); - DEBUGASSERT(group); + DEBUGASSERT(group && tcb); /* First, find thread's structure in the private data set. */ @@ -200,9 +201,8 @@ int pthread_completejoin(pid_t pid, FAR void *exit_value) pjoin = pthread_findjoininfo(group, pid); if (!pjoin) { - serr("ERROR: Could not find join info, pid=%d\n", pid); nxmutex_unlock(&group->tg_joinlock); - return ERROR; + return tcb->flags & TCB_FLAG_DETACHED ? OK : ERROR; } else {