diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-12 19:58:45 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-12 19:58:45 +0000 |
commit | 499c8c86de6757b39eaaf0f2b96a5b070f085b9b (patch) | |
tree | 84c6da5c61268158365bdafe58f546b34a0b8a91 /nuttx/sched/task_setup.c | |
parent | 5a180ec4940c993311eedddaa13194f9977968f1 (diff) | |
download | nuttx-499c8c86de6757b39eaaf0f2b96a5b070f085b9b.tar.gz nuttx-499c8c86de6757b39eaaf0f2b96a5b070f085b9b.tar.bz2 nuttx-499c8c86de6757b39eaaf0f2b96a5b070f085b9b.zip |
Fix a *critical* bug in the task exit logic. Implements SIGCHILD
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5513 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/task_setup.c')
-rw-r--r-- | nuttx/sched/task_setup.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/nuttx/sched/task_setup.c b/nuttx/sched/task_setup.c index 8721b39ec..c5dd8ca3a 100644 --- a/nuttx/sched/task_setup.c +++ b/nuttx/sched/task_setup.c @@ -147,6 +147,34 @@ static int task_assignpid(FAR _TCB *tcb) } /**************************************************************************** + * Name: task_saveparent + * + * Description: + * Save the task ID of the parent task in the child task's TCB. + * + * Parameters: + * tcb - The TCB of the new, child task. + * + * Returned Value: + * None + * + * Assumptions: + * The parent of the new task is the task at the head of the ready-to-run + * list. + * + ****************************************************************************/ + +#ifdef CONFIG_SCHED_HAVE_PARENT +static inline void task_saveparent(FAR _TCB *tcb) +{ + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + tcb->parent = rtcb->pid; +} +#else +# define task_saveparent(tcb) +#endif + +/**************************************************************************** * Name: task_dupdspace * * Description: @@ -161,6 +189,8 @@ static int task_assignpid(FAR _TCB *tcb) * None * * Assumptions: + * The parent of the new task is the task at the head of the ready-to-run + * list. * ****************************************************************************/ @@ -231,6 +261,10 @@ int task_schedsetup(FAR _TCB *tcb, int priority, start_t start, main_t main) tcb->start = start; tcb->entry.main = main; + /* Save the task ID of the parent task in the TCB */ + + task_saveparent(tcb); + /* exec(), pthread_create(), task_create(), and vfork() all * inherit the signal mask of the parent thread. */ @@ -243,7 +277,7 @@ int task_schedsetup(FAR _TCB *tcb, int priority, start_t start, main_t main) * until it is activated. */ - tcb->task_state = TSTATE_TASK_INVALID; + tcb->task_state = TSTATE_TASK_INVALID; /* Clone the parent tasks D-Space (if it was running PIC). This * must be done before calling up_initial_state() so that the |