Add logic to retain child task exit status if so configured

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5553 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2013-01-23 22:23:46 +00:00
parent f86f863834
commit 340a72b7cd
23 changed files with 846 additions and 223 deletions
+22 -1
View File
@@ -71,6 +71,9 @@
int task_reparent(pid_t ppid, pid_t chpid)
{
#ifdef CONFIG_SCHED_CHILD_STATUS
FAR struct child_status_s *child;
#endif
_TCB *ptcb;
_TCB *chtcb;
_TCB *otcb;
@@ -127,12 +130,30 @@ int task_reparent(pid_t ppid, pid_t chpid)
/* Then reparent the child */
chtcb->parent = ppid; /* The task specified by ppid is the new parent */
#ifdef CONFIG_SCHED_CHILD_STATUS
/* Remove the child status entry from old parent TCB */
child = task_removechild(otcb, chpid);
if (child)
{
/* Add the child status entry to the new parent TCB */
task_addchild(ptcb, child);
ret = OK;
}
else
{
ret = -ENOENT;
}
#else
DEBUGASSERT(otcb->nchildren > 0);
chtcb->parent = ppid; /* The task specified by ppid is the new parent */
otcb->nchildren--; /* The orignal parent now has one few children */
ptcb->nchildren++; /* The new parent has one additional child */
ret = OK;
#endif
errout_with_ints:
irqrestore(flags);