コード例 #1
0
ファイル: sig_queue.c プロジェクト: acassis/ros2_nuttx
int sigqueue(int pid, int signo, void *sival_ptr)
#endif
{
#ifdef CONFIG_SCHED_HAVE_PARENT
  FAR struct tcb_s *rtcb = this_task();
#endif
  siginfo_t info;
  int ret;

#ifdef CONFIG_CAN_PASS_STRUCTS
  sdbg("pid=0x%08x signo=%d value=%d\n", pid, signo, value.sival_int);
#else
  sdbg("pid=0x%08x signo=%d value=%p\n", pid, signo, sival_ptr);
#endif

  /* Sanity checks */

  if (!GOOD_SIGNO(signo))
    {
      ret = -EINVAL;
      goto errout;
    }

  /* Create the siginfo structure */

  info.si_signo           = signo;
  info.si_code            = SI_QUEUE;
  info.si_errno           = OK;
#ifdef CONFIG_CAN_PASS_STRUCTS
  info.si_value           = value;
#else
  info.si_value.sival_ptr = sival_ptr;
#endif
#ifdef CONFIG_SCHED_HAVE_PARENT
  info.si_pid             = rtcb->pid;
  info.si_status          = OK;
#endif

  /* Send the signal */

  sched_lock();
  ret = sig_dispatch(pid, &info);
  sched_unlock();

  /* Check for errors */

  if (ret < 0)
    {
      goto errout;
    }

  return OK;

errout:
  set_errno(-ret);
  return ERROR;
}
コード例 #2
0
ファイル: sig_kill.c プロジェクト: nodesign/nuttx-kernel
int kill(pid_t pid, int signo)
{
#ifdef CONFIG_SCHED_HAVE_PARENT
  FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
#endif
  siginfo_t info;
  int ret;

  /* We do not support sending signals to process groups */

  if (pid <= 0)
    {
      ret = -ENOSYS;
      goto errout;
    }

  /* Make sure that the signal is valid */

  if (!GOOD_SIGNO(signo))
    {
      ret = -EINVAL;
      goto errout;
    }

  /* Keep things stationary through the following */

  sched_lock();

  /* Create the siginfo structure */

  info.si_signo           = signo;
  info.si_code            = SI_USER;
  info.si_errno           = EINTR;
  info.si_value.sival_ptr = NULL;
#ifdef CONFIG_SCHED_HAVE_PARENT
  info.si_pid             = rtcb->pid;
  info.si_status          = OK;
#endif

  /* Send the signal */

  ret = sig_dispatch(pid, &info);
  sched_unlock();

  if (ret < 0)
    {
      goto errout;
    }

  return OK;

errout:
  set_errno(-ret);
  return ERROR;
}
コード例 #3
0
ファイル: sig_mqnotempty.c プロジェクト: FreddieChopin/NuttX
int sig_mqnotempty(int pid, int signo, void *sival_ptr)
#endif
{
#ifdef CONFIG_SCHED_HAVE_PARENT
  FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
#endif
  siginfo_t info;
  int ret;

#ifdef CONFIG_CAN_PASS_STRUCTS
  sdbg("pid=%p signo=%d value=%d\n", pid, signo, value.sival_int);
#else
  sdbg("pid=%p signo=%d sival_ptr=%p\n", pid, signo, sival_ptr);
#endif

  /* Verify that we can perform the signalling operation */

  if (!GOOD_SIGNO(signo))
    {
      return -EINVAL;
    }

  /* Create the siginfo structure */

  info.si_signo           = signo;
  info.si_code            = SI_MESGQ;
#ifdef CONFIG_CAN_PASS_STRUCTS
  info.si_value           = value;
#else
  info.si_value.sival_ptr = sival_ptr;
#endif
#ifdef CONFIG_SCHED_HAVE_PARENT
  info.si_pid             = rtcb->pid;
  info.si_status          = OK;
#endif

  /* Process the receipt of the signal */

  sched_lock();
  ret = sig_dispatch(pid, &info);
  sched_unlock();

  return ret;
}
コード例 #4
0
ファイル: timer_settime.c プロジェクト: casro/vrbrain_nuttx
static inline void timer_sigqueue(FAR struct posix_timer_s *timer)
{
  siginfo_t info;

  /* Create the siginfo structure */

  info.si_signo           = timer->pt_signo;
  info.si_code            = SI_TIMER;
#ifdef CONFIG_CAN_PASS_STRUCTS
  info.si_value           = timer->pt_value;
#else
  info.si_value.sival_ptr = timer->pt_value.sival_ptr;
#endif
#ifdef CONFIG_SCHED_HAVE_PARENT
  info.si_pid             = 0;  /* Not applicable */
  info.si_status          = OK;
#endif

  /* Send the signal */

  (void)sig_dispatch(timer->pt_owner, &info);
}