You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2020/12/02 00:47:19 UTC

[incubator-nuttx] branch master updated: sched/sched/sched_waitpid.c: Discard the correct child entry

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

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


The following commit(s) were added to refs/heads/master by this push:
     new bd79eaa  sched/sched/sched_waitpid.c: Discard the correct child entry
bd79eaa is described below

commit bd79eaa5a6218bb16e767e208b63e9acfea25884
Author: Yoshinori Sugino <ys...@gmail.com>
AuthorDate: Wed Dec 2 02:26:59 2020 +0900

    sched/sched/sched_waitpid.c: Discard the correct child entry
    
    Summary:
     - Discard the correct child entry after receiving SIGCHLD.
    
    Impact:
     - waitpid, wait
    
    Testing:
    hifive1-revb:nsh (CONFIG_SCHED_HAVE_PARENT=y, CONFIG_SCHED_CHILD_STATUS=y, CONFIG_SIG_DEFAULT=y)
    on QEMU
    
    static int task_main(int argc, char *argv[])
    {
      sleep(1);
      return 0;
    }
    
    int main(int argc, FAR char *argv[])
    {
      pid_t pid1;
      pid_t pid2;
      int status;
    
      task_create("task1", 224, 1024, task_main, NULL);
      task_create("task2", 224, 1024, task_main, NULL);
    
      pid1 = waitpid(-1, &status, 0);
      pid2 = waitpid(-1, &status, 0);
    
      assert(pid1 != pid2);
    
      return 0;
    }
---
 sched/sched/sched_waitpid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c
index fbf4fa6..40534b6 100644
--- a/sched/sched/sched_waitpid.c
+++ b/sched/sched/sched_waitpid.c
@@ -442,7 +442,7 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options)
             {
               /* Recover the exiting child */
 
-              child = group_exit_child(rtcb->group);
+              child = group_find_child(rtcb->group, info.si_pid);
               DEBUGASSERT(child != NULL);
 
               /* Discard the child entry, if we have one */