mirror of
https://github.com/apache/nuttx.git
synced 2026-10-11 16:20:21 +00:00
sched/pthread: return ESRCH when thread not found at pthread_detach
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_detach.html If an implementation detects that the value specified by the thread argument to pthread_detach() does not refer to a joinable thread, it is recommended that the function should fail and report an [EINVAL] error. If an implementation detects use of a thread ID after the end of its lifetime, it is recommended that the function should fail and report an [ESRCH] error. Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
parent
0623300b49
commit
ff6ba02378
1 changed files with 16 additions and 1 deletions
|
|
@ -76,8 +76,23 @@ int pthread_detach(pthread_t thread)
|
|||
pjoin = pthread_findjoininfo(group, (pid_t)thread);
|
||||
if (!pjoin)
|
||||
{
|
||||
FAR struct tcb_s *tcb = nxsched_get_tcb((pid_t)thread);
|
||||
|
||||
serr("ERROR: Could not find thread entry\n");
|
||||
ret = EINVAL;
|
||||
|
||||
if (tcb == NULL)
|
||||
{
|
||||
ret = ESRCH;
|
||||
}
|
||||
|
||||
/* The thread is still active but has no join info. In that
|
||||
* case, it must be a task and not a pthread.
|
||||
*/
|
||||
|
||||
else
|
||||
{
|
||||
ret = EINVAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue