Beispiel #1
0
static int sig_queueaction(FAR struct tcb_s *stcb, siginfo_t *info)
{
  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 */

  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.
   */

  if ((sigact) && (sigact->act.sa_u._sa_sigaction))
    {
      /* Allocate a new element for the signal queue.  NOTE:
       * sig_allocatependingsigaction will force a system crash if it is
       * unable to allocate memory for the signal data */

      sigq = sig_allocatependingsigaction();
      if (!sigq)
        {
          ret = -ENOMEM;
        }
      else
        {
          /* Populate the new signal queue element */

          sigq->action.sighandler = sigact->act.sa_u._sa_sigaction;
          sigq->mask = sigact->act.sa_mask;
          memcpy(&sigq->info, info, sizeof(siginfo_t));

          /* Put it at the end of the pending signals list */

          flags = enter_critical_section();
          sq_addlast((FAR sq_entry_t *)sigq, &(stcb->sigpendactionq));
          leave_critical_section(flags);
        }
    }

  sched_unlock();
  return ret;
}
Beispiel #2
0
static int sig_queueaction(FAR _TCB *stcb, siginfo_t *info)
{
  FAR sigactq_t *sigact;
  FAR sigq_t    *sigq;
  irqstate_t     saved_state;
  int            ret = OK;

  sched_lock();

  /* Find the sigaction associated with this signal */

  sigact = sig_findaction(stcb, info->si_signo);

  /* Check if a valid signal handler is available and if the signal is
   * unblocked.  NOTE:  There is no default action.
   */

  if ((sigact) && (sigact->act.sa_u._sa_sigaction))
    {
      /* Allocate a new element for the signal queue.  NOTE: sig_allocatependingsigaction
       * will force a system crash if it is unable to allocate memory for the
       * signal data */

      sigq = sig_allocatependingsigaction();
      if (!sigq) ret = ERROR;
      else
        {
          /* Populate the new signal queue element */

           sigq->action.sighandler = sigact->act.sa_u._sa_sigaction;
           sigq->mask = sigact->act.sa_mask;
           memcpy(&sigq->info, info, sizeof(siginfo_t));

           /* Put it at the end of the pending signals list */

           saved_state = irqsave();
           sq_addlast((FAR sq_entry_t*)sigq, &(stcb->sigpendactionq));
           irqrestore(saved_state);
        }
    }

  sched_unlock();
  return ret;
}