This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 7739ff12933e86db90cb27b6fa21fdf65dac1282 Author: yushuailong <[email protected]> AuthorDate: Tue Oct 13 20:48:58 2026 +0800 fix(sched/task): update parent after status migration Delay updating the child group's parent PID until child-status accounting has been transferred successfully. If the old parent is expected to retain status but its child entry is missing, task_reparent() now returns -ENOENT without leaving the child associated with a partially updated parent. Apply the transactional update to both task-group configurations. Assisted-by: OpenAI:Codex Signed-off-by: yushuailong <[email protected]> --- sched/task/task_reparent.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sched/task/task_reparent.c b/sched/task/task_reparent.c index 6c678db56d9..ce82b04687b 100644 --- a/sched/task/task_reparent.c +++ b/sched/task/task_reparent.c @@ -147,8 +147,6 @@ int task_reparent(pid_t ppid, pid_t chpid) * all members of the child's task group. */ - chgrp->tg_ppid = ppid; - #ifdef CONFIG_SCHED_CHILD_STATUS /* Remove the child status entry from old parent task group */ @@ -194,6 +192,11 @@ int task_reparent(pid_t ppid, pid_t chpid) #endif /* CONFIG_SCHED_CHILD_STATUS */ + if (ret == OK) + { + chgrp->tg_ppid = ppid; + } + errout_with_ints: leave_critical_section(flags); return ret; @@ -267,8 +270,6 @@ int task_reparent(pid_t ppid, pid_t chpid) * parent. */ - chtcb->group->tg_ppid = ppid; - #ifdef CONFIG_SCHED_CHILD_STATUS /* Remove the child status entry from old parent TCB */ @@ -315,6 +316,11 @@ int task_reparent(pid_t ppid, pid_t chpid) #endif /* CONFIG_SCHED_CHILD_STATUS */ + if (ret == OK) + { + chtcb->group->tg_ppid = ppid; + } + errout_with_ints: leave_critical_section(flags); return ret;
