diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-26 17:28:20 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-26 17:28:20 +0000 |
commit | a1aa13f62853491f8bd96a3dea0f0427fa83ad05 (patch) | |
tree | 86bcd215a785d7499f6472475df1c6c879574751 /nuttx/sched/sched_waitpid.c | |
parent | 239e2808cca6ee4c356d087bc83889fc57e64307 (diff) | |
download | px4-firmware-a1aa13f62853491f8bd96a3dea0f0427fa83ad05.tar.gz px4-firmware-a1aa13f62853491f8bd96a3dea0f0427fa83ad05.tar.bz2 px4-firmware-a1aa13f62853491f8bd96a3dea0f0427fa83ad05.zip |
Don't keep the parent task's task ID in the child task's TCB. Instead, keep the parent task group IN the child task's task group.
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5566 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/sched_waitpid.c')
-rw-r--r-- | nuttx/sched/sched_waitpid.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/nuttx/sched/sched_waitpid.c b/nuttx/sched/sched_waitpid.c index 4af7f7ef3..0285c2673 100644 --- a/nuttx/sched/sched_waitpid.c +++ b/nuttx/sched/sched_waitpid.c @@ -172,16 +172,12 @@ * * Assumptions: * - *****************************************************************************/ - -/*************************************************************************** - * NOTE: This is a partially functional, experimental version of waitpid() + * Compatibility + * If there is no SIGCHLD signal supported (CONFIG_SCHED_HAVE_PARENT not + * defined), then waitpid() is still available, but does not obey the + * restriction that the pid be a child of the caller. * - * If there is no SIGCHLD signal supported (CONFIG_SCHED_HAVE_PARENT not - * defined), then waitpid() is still available, but does not obey the - * restriction that the pid be a child of the caller. - * - ***************************************************************************/ + *****************************************************************************/ #ifndef CONFIG_SCHED_HAVE_PARENT pid_t waitpid(pid_t pid, int *stat_loc, int options) @@ -325,7 +321,11 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) /* Get the TCB corresponding to this PID and make sure it is our child. */ ctcb = sched_gettcb(pid); - if (!ctcb || ctcb->parent != rtcb->pid) +#ifdef HAVE_GROUP_MEMBERS + if (!ctcb || ctcb->group->tg_pgid != rtcb->group->tg_gid) +#else + if (!ctcb || ctcb->ppid != rtcb->pid) +#endif { err = ECHILD; goto errout_with_errno; @@ -337,7 +337,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) { /* Check if this specific pid has allocated child status? */ - if (task_findchild(rtcb, pid) == NULL) + if (group_findchild(rtcb->group, pid) == NULL) { err = ECHILD; goto errout_with_errno; @@ -357,7 +357,11 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) /* Get the TCB corresponding to this PID and make sure it is our child. */ ctcb = sched_gettcb(pid); - if (!ctcb || ctcb->parent != rtcb->pid) +#ifdef HAVE_GROUP_MEMBERS + if (!ctcb || ctcb->group->tg_pgid != rtcb->group->tg_gid) +#else + if (!ctcb || ctcb->ppid != rtcb->pid) +#endif { err = ECHILD; goto errout_with_errno; @@ -383,7 +387,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) */ DEBUGASSERT(!retains || rtcb->group->tg_children); - if (retains && (child = task_exitchild(rtcb)) != NULL) + if (retains && (child = group_exitchild(rtcb->group)) != NULL) { /* A child has exited. Apparently we missed the signal. * Return the saved exit status. @@ -395,8 +399,8 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) /* Discard the child entry and break out of the loop */ - (void)task_removechild(rtcb, child->ch_pid); - task_freechild(child); + (void)group_removechild(rtcb->group, child->ch_pid); + group_freechild(child); break; } } @@ -407,7 +411,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) { /* Get the current status of the child task. */ - child = task_findchild(rtcb, pid); + child = group_findchild(rtcb->group, pid); DEBUGASSERT(child); /* Did the child exit? */ @@ -420,8 +424,8 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) /* Discard the child entry and break out of the loop */ - (void)task_removechild(rtcb, pid); - task_freechild(child); + (void)group_removechild(rtcb->group, pid); + group_freechild(child); break; } } |