Use SIGCHLD with waitpid(); implemented wait() and waitid()

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5515 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2013-01-13 18:53:00 +00:00
parent ffda55b34a
commit b3f3dd123c
23 changed files with 1079 additions and 95 deletions
+19 -5
View File
@@ -217,6 +217,20 @@ static inline void task_sigchild(FAR _TCB *tcb, int status)
return;
}
/* Decrement the number of children from this parent */
DEBUGASSERT(ptcb->nchildren > 0);
ptcb->nchildren--;
/* Set the parent to an impossible PID. We do this because under certain
* conditions, task_exithook() can be called multiple times. If this
* function is called again, sched_gettcb() will fail on the invalid
* parent PID above, nchildren will be decremented once and all will be
* well.
*/
tcb->parent = INVALID_PROCESS_ID;
/* Create the siginfo structure. We don't actually know the cause. That
* is a bug. Let's just say that the child task just exit-ted for now.
*/
@@ -246,7 +260,7 @@ static inline void task_sigchild(FAR _TCB *tcb, int status)
*
****************************************************************************/
#ifdef CONFIG_SCHED_WAITPID
#if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_SCHED_HAVE_PARENT)
static inline void task_exitwakeup(FAR _TCB *tcb, int status)
{
/* Wakeup any tasks waiting for this task to exit */
@@ -310,14 +324,14 @@ void task_exithook(FAR _TCB *tcb, int status)
task_atexit(tcb);
/* Send SIGCHLD to the parent of the exiting task */
task_sigchild(tcb, status);
/* Call any registered on_exit function(s) */
task_onexit(tcb, status);
/* Send SIGCHLD to the parent of the exit-ing task */
task_sigchild(tcb, status);
/* Wakeup any tasks waiting for this task to exit */
task_exitwakeup(tcb, status);