sched/waitpid: Preserve child status with WNOWAIT.

When waitpid(-1) finds an exited child in the retained status list, honor
WNOWAIT instead of unconditionally removing and freeing the child entry.
This makes the any-child path consistent with the specific-PID and SIGCHLD
paths.

Assisted-by: OpenAI Codex
Signed-off-by: yushuailong <yyyusl@qq.com>
This commit is contained in:
yushuailong 2026-09-26 10:52:45 +08:00 • committed by Alan C. Assis
parent 556f0bc0a6
commit d5c4433a01

View file

@ -93,10 +93,14 @@ int waittcb(FAR struct tcb_s *rtcb, pid_t pid, int options,
ret = child->ch_pid;
/* Discard the child entry and break out of the loop */
/* Discard the child entry unless WNOWAIT is set */
if ((options & WNOWAIT) == 0)
{
group_remove_child(rtcb->group, child->ch_pid);
group_free_child(child);
}
group_remove_child(rtcb->group, child->ch_pid);
group_free_child(child);
break;
}
}