You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/12/05 14:45:49 UTC
[incubator-nuttx] 01/02: sched/sched/sched_waitid.c: Fix an error
that occurs when a waiting task has already finished
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 1a9a71f47c2471cf48a7d059d3d447f5dd1c14cd
Author: Yoshinori Sugino <ys...@gmail.com>
AuthorDate: Fri Dec 4 15:12:06 2020 +0900
sched/sched/sched_waitid.c: Fix an error that occurs when a waiting task has already finished
Summary:
- Fix an error that occurs when a waiting task has already finished.
Impact:
- waitid
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[])
{
return 0;
}
int main(int argc, FAR char *argv[])
{
siginfo_t info;
int pid;
int ret;
pid = task_create("task", 224, 1024, task_main, NULL);
sleep(1);
ret = waitid(P_PID, pid, &info, WEXITED);
assert(ret == 0);
return 0;
}
---
sched/sched/sched_waitid.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/sched/sched/sched_waitid.c b/sched/sched/sched_waitid.c
index 2001934..8aac112 100644
--- a/sched/sched/sched_waitid.c
+++ b/sched/sched/sched_waitid.c
@@ -178,15 +178,17 @@ int nx_waitid(int idtype, id_t id, FAR siginfo_t *info, int options)
*/
ctcb = nxsched_get_tcb((pid_t)id);
-
+ if (ctcb != NULL)
+ {
#ifdef HAVE_GROUP_MEMBERS
- if (ctcb == NULL || ctcb->group->tg_pgrpid != rtcb->group->tg_grpid)
+ if (ctcb->group->tg_pgrpid != rtcb->group->tg_grpid)
#else
- if (ctcb == NULL || ctcb->group->tg_ppid != rtcb->pid)
+ if (ctcb->group->tg_ppid != rtcb->pid)
#endif
- {
- ret = -ECHILD;
- goto errout;
+ {
+ ret = -ECHILD;
+ goto errout;
+ }
}
/* Does this task retain child status? */