This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit d5c4433a019e267feaf13b9f2282b8ecc1f3ecda
Author: yushuailong <[email protected]>
AuthorDate: Sat Sep 26 10:52:45 2026 +0800

    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 <[email protected]>
---
 sched/sched/sched_waitpid.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c
index 25e326c36f1..484a2ce3307 100644
--- a/sched/sched/sched_waitpid.c
+++ b/sched/sched/sched_waitpid.c
@@ -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;
             }
         }

Reply via email to