Squashed commit of the following:
Replace all calls to sigqueue() in the OS proper with calls to nxsig_queue() to avoid accessing the errno variable.
sched/signal: Add nxsig_queue() which is functionally equivalent to sigqueue() except that it does not modify the errno variable.
This commit is contained in:
parent
2318f895df
commit
4810499d3a
18 changed files with 220 additions and 112 deletions
|
|
@ -58,9 +58,10 @@
|
|||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/random.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/input/ajoystick.h>
|
||||
#include <nuttx/random.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
|
|
@ -376,10 +377,12 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv)
|
|||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
union sigval value;
|
||||
value.sival_int = (int)sample;
|
||||
(void)sigqueue(opriv->ao_pid, opriv->ao_notify.an_signo, value);
|
||||
|
||||
(void)nxsig_queue(opriv->ao_pid, opriv->ao_notify.an_signo,
|
||||
value);
|
||||
#else
|
||||
(void)sigqueue(opriv->ao_pid, opriv->ao_notify.dn.signo,
|
||||
(FAR void *)sample);
|
||||
(void)nxsig_queue(opriv->ao_pid, opriv->ao_notify.dn.signo,
|
||||
(FAR void *)sample);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -54,9 +54,10 @@
|
|||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/random.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/input/buttons.h>
|
||||
#include <nuttx/random.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
|
|
@ -358,10 +359,11 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv)
|
|||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
union sigval value;
|
||||
value.sival_int = (int)sample;
|
||||
(void)sigqueue(opriv->bo_pid, opriv->bo_notify.bn_signo, value);
|
||||
(void)nxsig_queue(opriv->bo_pid, opriv->bo_notify.bn_signo,
|
||||
value);
|
||||
#else
|
||||
(void)sigqueue(opriv->bo_pid, opriv->bo_notify.dn.signo,
|
||||
(FAR void *)sample);
|
||||
(void)nxsig_queue(opriv->bo_pid, opriv->bo_notify.dn.signo,
|
||||
(FAR void *)sample);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -58,9 +58,10 @@
|
|||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/random.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/input/djoystick.h>
|
||||
#include <nuttx/random.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
|
|
@ -376,10 +377,11 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv)
|
|||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
union sigval value;
|
||||
value.sival_int = (int)sample;
|
||||
(void)sigqueue(opriv->do_pid, opriv->do_notify.dn_signo, value);
|
||||
(void)nxsig_queue(opriv->do_pid, opriv->do_notify.dn_signo,
|
||||
value);
|
||||
#else
|
||||
(void)sigqueue(opriv->do_pid, opriv->do_notify.dn.signo,
|
||||
(FAR void *)sample);
|
||||
(void)nxsig_queue(opriv->do_pid, opriv->do_notify.dn.signo,
|
||||
(FAR void *)sample);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/net/phy.h>
|
||||
|
||||
#ifdef CONFIG_ARCH_PHY_INTERRUPT
|
||||
|
|
@ -251,18 +252,14 @@ static int phy_handler(int irq, FAR void *context, FAR void *arg)
|
|||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
value.sival_ptr = client->arg;
|
||||
ret = sigqueue(client->pid, client->signo, value);
|
||||
ret = nxsig_queue(client->pid, client->signo, value);
|
||||
#else
|
||||
ret = sigqueue(client->pid, client->signo, client->arg);
|
||||
ret = nxsig_queue(client->pid, client->signo, client->arg);
|
||||
#endif
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
DEBUGASSERT(errcode > 0);
|
||||
|
||||
nerr("ERROR: sigqueue failed: %d\n", errcode);
|
||||
UNUSED(errcode);
|
||||
nerr("ERROR: nxsig_queue failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
|
|
|||
|
|
@ -52,8 +52,9 @@
|
|||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/sensors/zerocross.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
|
@ -206,23 +207,23 @@ static void zerocross_interrupt(FAR const struct zc_lowerhalf_s *lower,
|
|||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
union sigval value;
|
||||
value.sival_int = (int)sample;
|
||||
(void)sigqueue(opriv->do_pid, opriv->do_notify.zc_signo, value);
|
||||
(void)nxsig_queue(opriv->do_pid, opriv->do_notify.zc_signo, value);
|
||||
#else
|
||||
(void)sigqueue(opriv->do_pid, opriv->do_notify.zc_signo,
|
||||
(FAR void *)sample);
|
||||
(void)nxsig_queue(opriv->do_pid, opriv->do_notify.zc_signo,
|
||||
(FAR void *)sample);
|
||||
#endif
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: zc_open
|
||||
*
|
||||
* Description:
|
||||
* This function is called whenever the PWM device is opened.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int zc_open(FAR struct file *filep)
|
||||
{
|
||||
|
|
@ -271,13 +272,13 @@ errout_with_sem:
|
|||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: zc_close
|
||||
*
|
||||
* Description:
|
||||
* This function is called when the PWM device is closed.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int zc_close(FAR struct file *filep)
|
||||
{
|
||||
|
|
@ -366,43 +367,45 @@ errout_with_exclsem:
|
|||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: zc_read
|
||||
*
|
||||
* Description:O
|
||||
* A dummy read method. This is provided only to satsify the VFS layer.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t zc_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
||||
static ssize_t zc_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
/* Return zero -- usually meaning end-of-file */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: zc_write
|
||||
*
|
||||
* Description:
|
||||
* A dummy write method. This is provided only to satsify the VFS layer.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t zc_write(FAR struct file *filep, FAR const char *buffer, size_t buflen)
|
||||
static ssize_t zc_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
/* Return a failure */
|
||||
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: zc_ioctl
|
||||
*
|
||||
* Description:
|
||||
* The standard ioctl method. This is where ALL of the PWM work is done.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int zc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/timers/oneshot.h>
|
||||
|
||||
|
|
@ -139,9 +140,9 @@ static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower,
|
|||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
value.sival_ptr = priv->od_arg;
|
||||
(void)sigqueue(priv->od_pid, priv->od_signo, value);
|
||||
(void)nxsig_queue(priv->od_pid, priv->od_signo, value);
|
||||
#else
|
||||
(void)sigqueue(priv->od_pid, priv->od_signo, priv->od_arg);
|
||||
(void)nxsig_queue(priv->od_pid, priv->od_signo, priv->od_arg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* drivers/timers/rtc.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -46,6 +46,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/timers/rtc.h>
|
||||
|
||||
|
|
@ -188,11 +189,11 @@ static void rtc_alarm_callback(FAR void *priv, int alarmid)
|
|||
/* Yes.. signal the alarm expriration */
|
||||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
(void)sigqueue(alarminfo->pid, alarminfo->signo,
|
||||
alarminfo->sigvalue);
|
||||
(void)nxsig_queue(alarminfo->pid, alarminfo->signo,
|
||||
alarminfo->sigvalue);
|
||||
#else
|
||||
(void)sigqueue(alarminfo->pid, alarminfo->signo,
|
||||
alarminfo->sigvalue->sival_ptr);
|
||||
(void)nxsig_queue(alarminfo->pid, alarminfo->signo,
|
||||
alarminfo->sigvalue->sival_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* drivers/timers/timer.c
|
||||
*
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Bob Doiron
|
||||
*
|
||||
|
|
@ -51,9 +51,10 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/timers/timer.h>
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
|
|
@ -138,9 +139,9 @@ static bool timer_notifier(FAR uint32_t *next_interval_us, FAR void *arg)
|
|||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
value.sival_ptr = upper->arg;
|
||||
(void)sigqueue(upper->pid, upper->signo, value);
|
||||
(void)nxsig_queue(upper->pid, upper->signo, value);
|
||||
#else
|
||||
(void)sigqueue(upper->pid, upper->signo, upper->arg);
|
||||
(void)nxsig_queue(upper->pid, upper->signo, upper->arg);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@
|
|||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/arp.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
|
|
@ -494,10 +495,11 @@ static void xbeenet_notify(FAR struct xbee_maccb_s *maccb,
|
|||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
union sigval value;
|
||||
value.sival_int = (int)notif->notiftype;
|
||||
(void)sigqueue(priv->xd_notify_pid, priv->xd_notify_signo, value);
|
||||
(void)nxsig_queue(priv->xd_notify_pid, priv->xd_notify_signo,
|
||||
value);
|
||||
#else
|
||||
(void)sigqueue(priv->xd_notify_pid, priv->xd_notify_signo,
|
||||
(FAR void *)notif->notiftype);
|
||||
(void)nxsig_queue(priv->xd_notify_pid, priv->xd_notify_signo,
|
||||
(FAR void *)notif->notiftype);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/signal.h>
|
||||
|
||||
#include "aio/aio.h"
|
||||
|
||||
#ifdef CONFIG_FS_AIO
|
||||
|
|
@ -80,7 +82,6 @@ int aio_signal(pid_t pid, FAR struct aiocb *aiocbp)
|
|||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
union sigval value;
|
||||
#endif
|
||||
int errcode;
|
||||
int status;
|
||||
int ret;
|
||||
|
||||
|
|
@ -93,17 +94,15 @@ int aio_signal(pid_t pid, FAR struct aiocb *aiocbp)
|
|||
if (aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL)
|
||||
{
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
status = sigqueue(pid, aiocbp->aio_sigevent.sigev_signo,
|
||||
ret = nxsig_queue(pid, aiocbp->aio_sigevent.sigev_signo,
|
||||
aiocbp->aio_sigevent.sigev_value);
|
||||
#else
|
||||
status = sigqueue(pid, aiocbp->aio_sigevent.sigev_sign,
|
||||
ret = nxsig_queue(pid, aiocbp->aio_sigevent.sigev_sign,
|
||||
aiocbp->aio_sigevent.sigev_value.sival_ptr);
|
||||
#endif
|
||||
if (status < 0)
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = get_errno();
|
||||
ferr("ERROR: sigqueue #1 failed: %d\n", errcode);
|
||||
ret = ERROR;
|
||||
ferr("ERROR: nxsig_queue #1 failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -126,22 +125,24 @@ int aio_signal(pid_t pid, FAR struct aiocb *aiocbp)
|
|||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
value.sival_ptr = aiocbp;
|
||||
status = sigqueue(pid, SIGPOLL, value);
|
||||
status = nxsig_queue(pid, SIGPOLL, value);
|
||||
#else
|
||||
status = sigqueue(pid, SIGPOLL, aiocbp);
|
||||
status = nxsig_queue(pid, SIGPOLL, aiocbp);
|
||||
#endif
|
||||
if (status && ret == OK)
|
||||
if (status < 0)
|
||||
{
|
||||
errcode = get_errno();
|
||||
ferr("ERROR: sigqueue #2 failed: %d\n", errcode);
|
||||
ret = ERROR;
|
||||
ferr("ERROR: nxsig_queue #2 failed: %d\n", status);
|
||||
if (ret >= OK)
|
||||
{
|
||||
ret = status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure that errno is set correctly on return */
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
set_errno(errcode);
|
||||
set_errno(-ret);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,47 @@
|
|||
|
||||
struct timespec; /* Forward reference */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsig_queue
|
||||
*
|
||||
* Description:
|
||||
* This function sends the signal specified by signo with the signal
|
||||
* parameter value to the process specified by pid.
|
||||
*
|
||||
* If the receiving process has the signal blocked via the sigprocmask,
|
||||
* the signal will pend until it is unmasked. Only one pending signal (per
|
||||
* signo) is retained. This is consistent with POSIX which states, "If
|
||||
* a subsequent occurrence of a pending signal is generated, it is
|
||||
* implementation defined as to whether the signal is delivered more than
|
||||
* once.
|
||||
*
|
||||
* This is an internal OS interface. It is functionally equivalent to
|
||||
* sigqueue() except that it does not modify the errno value.
|
||||
*
|
||||
* Parameters:
|
||||
* pid - Process ID of task to receive signal
|
||||
* signo - Signal number
|
||||
* value - Value to pass to task with signal
|
||||
*
|
||||
* Return Value:
|
||||
* This is an internal OS interface and should not be used by applications.
|
||||
* It follows the NuttX internal error return policy: Zero (OK) is
|
||||
* returned on success. A negated errno value is returned on failure.
|
||||
*
|
||||
* EGAIN - The limit of signals which may be queued has been reached.
|
||||
* EINVAL - sig was invalid.
|
||||
* EPERM - The process does not have permission to send the
|
||||
* signal to the receiving process.
|
||||
* ESRCH - No process has a PID matching pid.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
int nxsig_queue (int pid, int signo, union sigval value);
|
||||
#else
|
||||
int nxsig_queue(int pid, int signo, void *sival_ptr);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsig_kill
|
||||
*
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/cancelpt.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
|
@ -88,10 +89,10 @@ static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
|
|||
FAR struct tcb_s *tcb;
|
||||
siginfo_t info;
|
||||
|
||||
/* The logic below if equivalent to sigqueue(), but uses nxsig_tcbdispatch()
|
||||
* instead of nxsig_dispatch(). This avoids the group signal deliver logic
|
||||
* and assures, instead, that the signal is delivered specifically to this
|
||||
* thread that is known to be waiting on the signal.
|
||||
/* The logic below if equivalent to nxsig_queue(), but uses
|
||||
* nxsig_tcbdispatch() instead of nxsig_dispatch(). This avoids the group
|
||||
* signal deliver logic and assures, instead, that the signal is delivered
|
||||
* specifically to this thread that is known to be waiting on the signal.
|
||||
*/
|
||||
|
||||
/* Get the waiting TCB. sched_gettcb() might return NULL if the task has
|
||||
|
|
@ -123,7 +124,7 @@ static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
|
|||
#else /* HAVE_GROUP_MEMBERS */
|
||||
|
||||
/* Things are a little easier if there are not group members. We can just
|
||||
* use sigqueue().
|
||||
* use nxsig_queue().
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
|
|
@ -132,9 +133,9 @@ static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
|
|||
/* Send the specified signal to the specified task. */
|
||||
|
||||
value.sival_ptr = NULL;
|
||||
(void)sigqueue((int)pid, (int)signo, value);
|
||||
(void)nxsig_queue((int)pid, (int)signo, value);
|
||||
#else
|
||||
(void)sigqueue((int)pid, (int)signo, NULL);
|
||||
(void)nxsig_queue((int)pid, (int)signo, NULL);
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_GROUP_MEMBERS */
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/signal.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "signal/signal.h"
|
||||
|
||||
|
|
@ -56,10 +58,11 @@
|
|||
* Name: nxsig_mqnotempty
|
||||
*
|
||||
* Description:
|
||||
* This function is equivalent to sigqueue(), but supports the messaging
|
||||
* system's requirement to signal a task when a message queue becomes
|
||||
* non-empty. It is identical to sigqueue(), except that it sets the
|
||||
* si_code field in the siginfo structure to SI_MESGQ rather than SI_QUEUE.
|
||||
* This function is equivalent to nxsig_queue(), but supports the
|
||||
* messaging system's requirement to signal a task when a message queue
|
||||
* becomes non-empty. It is identical to nxsig_queue(), except that it
|
||||
* sets the si_code field in the siginfo structure to SI_MESGQ rather than
|
||||
* SI_QUEUE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_queue.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2013, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -45,6 +45,8 @@
|
|||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/signal.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "signal/signal.h"
|
||||
|
||||
|
|
@ -53,7 +55,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sigqueue
|
||||
* Name: nxsig_queue
|
||||
*
|
||||
* Description:
|
||||
* This function sends the signal specified by signo with the signal
|
||||
|
|
@ -64,7 +66,10 @@
|
|||
* signo) is retained. This is consistent with POSIX which states, "If
|
||||
* a subsequent occurrence of a pending signal is generated, it is
|
||||
* implementation defined as to whether the signal is delivered more than
|
||||
* once."
|
||||
* once.
|
||||
*
|
||||
* This is an internal OS interface. It is functionally equivalent to
|
||||
* sigqueue() except that it does not modify the errno value.
|
||||
*
|
||||
* Parameters:
|
||||
* pid - Process ID of task to receive signal
|
||||
|
|
@ -72,23 +77,22 @@
|
|||
* value - Value to pass to task with signal
|
||||
*
|
||||
* Return Value:
|
||||
* On success (at least one signal was sent), zero is returned. On
|
||||
* error, -1 is returned, and errno is set appropriately:
|
||||
* This is an internal OS interface and should not be used by applications.
|
||||
* It follows the NuttX internal error return policy: Zero (OK) is
|
||||
* returned on success. A negated errno value is returned on failure.
|
||||
*
|
||||
* EGAIN The limit of signals which may be queued has been reached.
|
||||
* EINVAL sig was invalid.
|
||||
* EPERM The process does not have permission to send the
|
||||
* signal to the receiving process.
|
||||
* ESRCH No process has a PID matching pid.
|
||||
*
|
||||
* Assumptions:
|
||||
* EGAIN - The limit of signals which may be queued has been reached.
|
||||
* EINVAL - sig was invalid.
|
||||
* EPERM - The process does not have permission to send the
|
||||
* signal to the receiving process.
|
||||
* ESRCH - No process has a PID matching pid.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
int sigqueue (int pid, int signo, union sigval value)
|
||||
int nxsig_queue (int pid, int signo, union sigval value)
|
||||
#else
|
||||
int sigqueue(int pid, int signo, void *sival_ptr)
|
||||
int nxsig_queue(int pid, int signo, void *sival_ptr)
|
||||
#endif
|
||||
{
|
||||
#ifdef CONFIG_SCHED_HAVE_PARENT
|
||||
|
|
@ -107,8 +111,7 @@ int sigqueue(int pid, int signo, void *sival_ptr)
|
|||
|
||||
if (!GOOD_SIGNO(signo))
|
||||
{
|
||||
ret = -EINVAL;
|
||||
goto errout;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Create the siginfo structure */
|
||||
|
|
@ -132,17 +135,61 @@ int sigqueue(int pid, int signo, void *sival_ptr)
|
|||
ret = nxsig_dispatch(pid, &info);
|
||||
sched_unlock();
|
||||
|
||||
/* Check for errors */
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
errout:
|
||||
set_errno(-ret);
|
||||
return ERROR;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sigqueue
|
||||
*
|
||||
* Description:
|
||||
* This function sends the signal specified by signo with the signal
|
||||
* parameter value to the process specified by pid.
|
||||
*
|
||||
* If the receiving process has the signal blocked via the sigprocmask,
|
||||
* the signal will pend until it is unmasked. Only one pending signal (per
|
||||
* signo) is retained. This is consistent with POSIX which states, "If
|
||||
* a subsequent occurrence of a pending signal is generated, it is
|
||||
* implementation defined as to whether the signal is delivered more than
|
||||
* once."
|
||||
*
|
||||
* Parameters:
|
||||
* pid - Process ID of task to receive signal
|
||||
* signo - Signal number
|
||||
* value - Value to pass to task with signal
|
||||
*
|
||||
* Return Value:
|
||||
* On success (at least one signal was sent), zero (OK) is returned. On
|
||||
* any failure, -1 (ERROR) is returned and errno varaible is set
|
||||
* appropriately:
|
||||
*
|
||||
* EGAIN - The limit of signals which may be queued has been reached.
|
||||
* EINVAL - sig was invalid.
|
||||
* EPERM - The process does not have permission to send the
|
||||
* signal to the receiving process.
|
||||
* ESRCH - No process has a PID matching pid.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
int sigqueue (int pid, int signo, union sigval value)
|
||||
#else
|
||||
int sigqueue(int pid, int signo, void *sival_ptr)
|
||||
#endif
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Let nxsig_queue() do all of the real work */
|
||||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
ret = nxsig_queue(pid, signo, value);
|
||||
#else
|
||||
ret = nxsig_queue(pid, signo, sival_ptr);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
set_errno(-ret);
|
||||
ret = ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ static void nxsig_timeout(int argc, wdparm_t itcb)
|
|||
* If the info argument is non-NULL, the selected signal number is stored
|
||||
* in the si_signo member and the cause of the signal is store din the
|
||||
* si_code member. The content of si_value is only meaningful if the
|
||||
* signal was generated by sigqueue().
|
||||
* signal was generated by sigqueue() (or nxsig_queue).
|
||||
*
|
||||
* This is an internal OS interface. It is functionally equivalent to
|
||||
* sigtimedwait() except that:
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ static void timer_timeout(int argc, wdparm_t itimer);
|
|||
* Name: timer_signotify
|
||||
*
|
||||
* Description:
|
||||
* This function basically reimplements sigqueue() so that the si_code can
|
||||
* be correctly set to SI_TIMER
|
||||
* This function basically reimplements nxsig_queue() so that the si_code
|
||||
* can be correctly set to SI_TIMER
|
||||
*
|
||||
* Parameters:
|
||||
* timer - A reference to the POSIX timer that just timed out
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_device.h>
|
||||
|
|
@ -792,10 +792,11 @@ static void mac802154dev_notify(FAR struct mac802154_maccb_s *maccb,
|
|||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
union sigval value;
|
||||
value.sival_int = (int)notif->notiftype;
|
||||
(void)sigqueue(dev->md_notify_pid, dev->md_notify_signo, value);
|
||||
(void)nxsig_queue(dev->md_notify_pid, dev->md_notify_signo,
|
||||
value);
|
||||
#else
|
||||
(void)sigqueue(dev->md_notify_pid, dev->md_notify_signo,
|
||||
(FAR void *)notif->notiftype);
|
||||
(void)nxsig_queue(dev->md_notify_pid, dev->md_notify_signo,
|
||||
(FAR void *)notif->notiftype);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@
|
|||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
|
|
@ -493,10 +494,11 @@ static void macnet_notify(FAR struct mac802154_maccb_s *maccb,
|
|||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
union sigval value;
|
||||
value.sival_int = (int)notif->notiftype;
|
||||
(void)sigqueue(priv->md_notify_pid, priv->md_notify_signo, value);
|
||||
(void)nxsig_queue(priv->md_notify_pid, priv->md_notify_signo,
|
||||
value);
|
||||
#else
|
||||
(void)sigqueue(priv->md_notify_pid, priv->md_notify_signo,
|
||||
(FAR void *)notif->notiftype);
|
||||
(void)nxsig_queue(priv->md_notify_pid, priv->md_notify_signo,
|
||||
(FAR void *)notif->notiftype);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue