diff --git a/sched/sched/sched_waitid.c b/sched/sched/sched_waitid.c index 8aac1122dc..3b119d3143 100644 --- a/sched/sched/sched_waitid.c +++ b/sched/sched/sched_waitid.c @@ -74,12 +74,15 @@ static void exited_child(FAR struct tcb_s *rtcb, * information). */ - info->si_signo = SIGCHLD; - info->si_code = CLD_EXITED; - info->si_errno = OK; - info->si_value.sival_ptr = NULL; - info->si_pid = child->ch_pid; - info->si_status = child->ch_status; + if (info) + { + info->si_signo = SIGCHLD; + info->si_code = CLD_EXITED; + info->si_errno = OK; + info->si_value.sival_ptr = NULL; + info->si_pid = child->ch_pid; + info->si_status = child->ch_status; + } /* Discard the child entry */ @@ -364,6 +367,19 @@ int nx_waitid(int idtype, id_t id, FAR siginfo_t *info, int options) { /* Yes... return success */ +#ifdef CONFIG_SCHED_CHILD_STATUS + if (retains) + { + child = group_find_child(rtcb->group, info->si_pid); + DEBUGASSERT(child); + + if ((child->ch_flags & CHILD_FLAG_EXITED) != 0) + { + exited_child(rtcb, child, NULL); + } + } +#endif + break; } } @@ -374,6 +390,19 @@ int nx_waitid(int idtype, id_t id, FAR siginfo_t *info, int options) { /* Return success */ +#ifdef CONFIG_SCHED_CHILD_STATUS + if (retains) + { + child = group_find_child(rtcb->group, info->si_pid); + + if (child && + (child->ch_flags & CHILD_FLAG_EXITED) != 0) + { + exited_child(rtcb, child, NULL); + } + } +#endif + break; }