sched/pthread: Don't do cancel when it is already in the exit process

When the task is already in the exit process,
do not execute pthread cancel and return ESRCH.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
zhangyuan21 2023-05-24 08:39:40 +08:00 committed by Xiang Xiao
parent 14202651b2
commit 671c5dc3d8
2 changed files with 14 additions and 0 deletions

View File

@ -65,6 +65,13 @@ int pthread_cancel(pthread_t thread)
return ESRCH;
}
/* Return ESRCH when thread was in exit processing */
if ((tcb->flags & TCB_FLAG_EXIT_PROCESSING) != 0)
{
return ESRCH;
}
/* Only pthreads should use this interface */
DEBUGASSERT((tcb->flags & TCB_FLAG_TTYPE_MASK) ==

View File

@ -328,6 +328,13 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info)
DEBUGASSERT(stcb != NULL && info != NULL);
/* Return ESRCH when thread was in exit processing */
if ((stcb->flags & TCB_FLAG_EXIT_PROCESSING) != 0)
{
return -ESRCH;
}
/* Don't actually send a signal for signo 0. */
if (info->si_signo == 0)