diff --git a/TODO b/TODO index 5351334ad5..724519cd31 100644 --- a/TODO +++ b/TODO @@ -11,7 +11,7 @@ nuttx/ (13) Task/Scheduler (sched/) (1) Memory Management (mm/) - (4) Signals (sched/signal, arch/) + (3) Signals (sched/signal, arch/) (2) pthreads (sched/pthread) (0) Message Queues (sched/mqueue) (6) Kernel/Protected Build @@ -360,17 +360,6 @@ o Signals (sched/signal, arch/) Status: Open Priority: Low. Even if there are only 31 usable signals, that is still a lot. - Title: THREAD COMMON SIGNAL HANDLING - Description: Signal handlers are assigned on a per thread basis. Signal lists - and data structures are a part of the TCB. This is incorrect. - Signal handlers are a global property of the task group: The - main thread and all of its child threads. Signal handlers for - all threads should be attach-able from the main thread, for - example. - Status: Open - Priority: Medium. This is a pretty big violation of the signal handling - principles. - o pthreads (sched/pthreads) ^^^^^^^^^^^^^^^^^ diff --git a/sched/group/group_signal.c b/sched/group/group_signal.c index 7b29e3d5d6..1f681928d9 100644 --- a/sched/group/group_signal.c +++ b/sched/group/group_signal.c @@ -89,12 +89,11 @@ struct group_signal_s static int group_signal_handler(pid_t pid, FAR void *arg) { FAR struct group_signal_s *info = (FAR struct group_signal_s *)arg; - FAR struct task_group_s *group; FAR struct tcb_s *tcb; FAR sigactq_t *sigact; int ret; - DEBUGASSERT(info); + DEBUGASSERT(tcb != NULL && tcb->group != NULL && info != NULL); /* Get the TCB associated with the group member */ @@ -154,10 +153,7 @@ static int group_signal_handler(pid_t pid, FAR void *arg) /* Is there also a action associated with the task group? */ - group = tcb->group; - DEBUGASSERT(group != NULL); - - sigact = sig_findaction(group, info->siginfo->si_signo); + sigact = sig_findaction(tcb->group, info->siginfo->si_signo); if (sigact) { /* Yes.. then use this thread. The requirement is this: diff --git a/sched/signal/sig_dispatch.c b/sched/signal/sig_dispatch.c index 2fedb96088..1d3526d5a1 100644 --- a/sched/signal/sig_dispatch.c +++ b/sched/signal/sig_dispatch.c @@ -72,20 +72,17 @@ static int sig_queueaction(FAR struct tcb_s *stcb, siginfo_t *info) { - FAR struct task_group_s *group; FAR sigactq_t *sigact; FAR sigq_t *sigq; irqstate_t flags; int ret = OK; sched_lock(); + DEBUGASSERT(stcb != NULL && stcb->group != NULL); /* Find the group sigaction associated with this signal */ - DEBUGASSERT(stcb != NULL && stcb->group != NULL); - - group = stcb->group; - sigact = sig_findaction(group, info->si_signo); + sigact = sig_findaction(stcb->group, info->si_signo); /* Check if a valid signal handler is available and if the signal is * unblocked. NOTE: There is no default action. @@ -202,7 +199,7 @@ static FAR sigpendq_t *sig_findpendingsignal(FAR struct task_group_s *group, FAR sigpendq_t *sigpend = NULL; irqstate_t flags; - DEBUGASSERT(group); + DEBUGASSERT(group != NULL); /* Pending sigals can be added from interrupt level. */ @@ -232,13 +229,14 @@ static FAR sigpendq_t *sig_findpendingsignal(FAR struct task_group_s *group, static FAR sigpendq_t *sig_addpendingsignal(FAR struct tcb_s *stcb, FAR siginfo_t *info) { - FAR struct task_group_s *group = stcb->group; + FAR struct task_group_s *group; FAR sigpendq_t *sigpend; irqstate_t flags; - DEBUGASSERT(group); + DEBUGASSERT(stcb != NULL && stcb->group != NULL); + group = stcb->group; - /* Check if the signal is already pending */ + /* Check if the signal is already pending for the group */ sigpend = sig_findpendingsignal(group, info->si_signo); if (sigpend) @@ -248,7 +246,7 @@ static FAR sigpendq_t *sig_addpendingsignal(FAR struct tcb_s *stcb, memcpy(&sigpend->info, info, sizeof(siginfo_t)); } - /* No... There is nothing pending for this signo */ + /* No... There is nothing pending in the group for this signo */ else { @@ -261,7 +259,7 @@ static FAR sigpendq_t *sig_addpendingsignal(FAR struct tcb_s *stcb, memcpy(&sigpend->info, info, sizeof(siginfo_t)); - /* Add the structure to the pending signal list */ + /* Add the structure to the group pending signal list */ flags = enter_critical_section(); sq_addlast((FAR sq_entry_t *)sigpend, &group->tg_sigpendingq);