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 91b4b0a91e57c67bda39b7270a25ec6437ff3810 Author: yushuailong <[email protected]> AuthorDate: Thu Sep 10 15:57:45 2026 +0800 sched: fix parent process check using wrong pid field Compare ctcb->group->tg_ppid against rtcb->group->tg_pid (the group leader PID) instead of rtcb->pid in waitid() and in the !CONFIG_SCHED_CHILD_STATUS path of waitpid(). Commit ece224a7e3 ("handle waitpid waitting tcb->group is NULL") rewrote the comparisons this way when adding the ctcb->group NULL guard, regressing what 90be95bb89 had correct: a non-group-leader thread calling waitid(P_PID) or waitpid() on a child always gets ECHILD. Assisted-by: OpenAI Codex Signed-off-by: yushuailong <[email protected]> --- sched/sched/sched_waitid.c | 5 +++-- sched/sched/sched_waitpid.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sched/sched/sched_waitid.c b/sched/sched/sched_waitid.c index 81955e44d15..330f26afec6 100644 --- a/sched/sched/sched_waitid.c +++ b/sched/sched/sched_waitid.c @@ -400,7 +400,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options) { /* Make sure that the thread it is our child. */ - if (ctcb->group->tg_ppid != rtcb->pid) + if (ctcb->group->tg_ppid != rtcb->group->tg_pid) { errcode = ECHILD; } @@ -437,7 +437,8 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options) ctcb = nxsched_get_tcb((pid_t)id); - if (!ctcb || !ctcb->group || ctcb->group->tg_ppid != rtcb->pid) + if (!ctcb || !ctcb->group || + ctcb->group->tg_ppid != rtcb->group->tg_pid) { errcode = ECHILD; } diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c index 49a70fe974d..25e326c36f1 100644 --- a/sched/sched/sched_waitpid.c +++ b/sched/sched/sched_waitpid.c @@ -373,7 +373,8 @@ pid_t nxsched_waitpid(pid_t pid, FAR int *stat_loc, int options) */ ctcb = nxsched_get_tcb(pid); - if (!ctcb || !ctcb->group || ctcb->group->tg_ppid != rtcb->pid || + if (!ctcb || !ctcb->group || + ctcb->group->tg_ppid != rtcb->group->tg_pid || (ctcb->flags & TCB_FLAG_EXIT_PROCESSING) != 0) { ret = -ECHILD;
