From 57d83907ddf2faaf3efdbf6d586bb330bc748fe1 Mon Sep 17 00:00:00 2001 From: guohao15 Date: Sat, 8 Feb 2025 06:47:45 +0000 Subject: [PATCH] bugfix: share kernel thread group should not dup files from caller group after this commits commit e7fa4cae6cbf567266985c8072db1f51ad480943 Author: Yanfeng Liu Date: Fri May 17 06:11:52 2024 +0800 sched/tcb: use shared group for kthreads all kernel thread share group idle and should not dup filelist to this group Signed-off-by: guohao15 Signed-off-by: dongjiuzhu1 --- sched/group/group_setuptaskfiles.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sched/group/group_setuptaskfiles.c b/sched/group/group_setuptaskfiles.c index 4af75193e05..cab58e82458 100644 --- a/sched/group/group_setuptaskfiles.c +++ b/sched/group/group_setuptaskfiles.c @@ -79,15 +79,19 @@ int group_setuptaskfiles(FAR struct task_tcb_s *tcb, #ifndef CONFIG_FDCLONE_DISABLE DEBUGASSERT(rtcb->group); - /* Duplicate the parent task's file descriptors */ + /* With the exception of kernel threads, duplicate the parent task's + * file descriptors. + */ - if (group != rtcb->group) + if (group != rtcb->group && + (tcb->cmn.flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) { ret = fdlist_copy(&rtcb->group->tg_fdlist, &group->tg_fdlist, actions, cloexec); } - if (ret >= 0 && actions != NULL) + if (ret >= 0 && actions != NULL && + (tcb->cmn.flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) { ret = spawn_file_actions(&tcb->cmn, actions); }