2013-02-05 20:50:37 +01:00
|
|
|
/****************************************************************************
|
2014-08-08 20:55:02 +02:00
|
|
|
* sched/signal/sig_dispatch.c
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2013-02-05 20:50:37 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2013-02-05 20:50:37 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-11-07 21:55:25 +01:00
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2020-11-20 08:52:26 +01:00
|
|
|
#include <inttypes.h>
|
2007-02-21 22:55:16 +01:00
|
|
|
#include <string.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <signal.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sched.h>
|
2021-05-18 08:59:14 +02:00
|
|
|
#include <assert.h>
|
2011-07-20 15:19:07 +02:00
|
|
|
#include <errno.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <debug.h>
|
2011-07-20 15:19:07 +02:00
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
#include <nuttx/irq.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <nuttx/arch.h>
|
2020-04-29 18:53:36 +02:00
|
|
|
#include <nuttx/signal.h>
|
2022-11-01 02:52:11 +01:00
|
|
|
#include <nuttx/queue.h>
|
2008-11-07 21:55:25 +01:00
|
|
|
|
2014-08-09 01:53:55 +02:00
|
|
|
#include "sched/sched.h"
|
2014-08-08 22:06:42 +02:00
|
|
|
#include "group/group.h"
|
2014-08-08 21:53:29 +02:00
|
|
|
#include "semaphore/semaphore.h"
|
2014-08-08 20:44:44 +02:00
|
|
|
#include "signal/signal.h"
|
2014-08-08 20:31:23 +02:00
|
|
|
#include "mqueue/mqueue.h"
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Private Functions
|
2013-02-05 20:50:37 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/****************************************************************************
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* Name: nxsig_queue_action
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Queue a signal action for delivery to a task.
|
|
|
|
*
|
2013-02-05 20:50:37 +01:00
|
|
|
* Returned Value:
|
|
|
|
* Returns 0 (OK) on success or a negated errno value on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
static int nxsig_queue_action(FAR struct tcb_s *stcb, siginfo_t *info)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR sigactq_t *sigact;
|
|
|
|
FAR sigq_t *sigq;
|
2016-02-14 15:17:46 +01:00
|
|
|
irqstate_t flags;
|
2007-02-27 22:17:21 +01:00
|
|
|
int ret = OK;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
sched_lock();
|
2016-02-18 16:21:43 +01:00
|
|
|
DEBUGASSERT(stcb != NULL && stcb->group != NULL);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-18 15:34:11 +01:00
|
|
|
/* Find the group sigaction associated with this signal */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
sigact = nxsig_find_action(stcb->group, info->si_signo);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* Check if a valid signal handler is available and if the signal is
|
2020-10-04 17:48:34 +02:00
|
|
|
* unblocked. NOTE: There is no default action.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
if ((sigact) && (sigact->act.sa_u._sa_sigaction))
|
|
|
|
{
|
2020-10-04 17:48:34 +02:00
|
|
|
/* Allocate a new element for the signal queue. NOTE:
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* nxsig_alloc_pendingsigaction will force a system crash if it is
|
2019-03-01 17:50:02 +01:00
|
|
|
* unable to allocate memory for the signal data.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
sigq = nxsig_alloc_pendingsigaction();
|
2013-02-05 20:50:37 +01:00
|
|
|
if (!sigq)
|
|
|
|
{
|
|
|
|
ret = -ENOMEM;
|
|
|
|
}
|
2007-02-18 00:21:28 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Populate the new signal queue element */
|
|
|
|
|
2015-10-08 03:59:14 +02:00
|
|
|
sigq->action.sighandler = sigact->act.sa_u._sa_sigaction;
|
|
|
|
sigq->mask = sigact->act.sa_mask;
|
2021-03-26 11:15:17 +01:00
|
|
|
if ((sigact->act.sa_flags & SA_NODEFER) == 0)
|
|
|
|
{
|
2023-03-23 21:36:14 +01:00
|
|
|
sigaddset(&sigq->mask, info->si_signo);
|
2021-03-26 11:15:17 +01:00
|
|
|
}
|
|
|
|
|
2015-10-08 03:59:14 +02:00
|
|
|
memcpy(&sigq->info, info, sizeof(siginfo_t));
|
2023-11-22 14:48:04 +01:00
|
|
|
sigq->info.si_user = sigact->act.sa_user;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2015-10-08 03:59:14 +02:00
|
|
|
/* Put it at the end of the pending signals list */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
flags = enter_critical_section();
|
2015-10-08 03:59:14 +02:00
|
|
|
sq_addlast((FAR sq_entry_t *)sigq, &(stcb->sigpendactionq));
|
2022-01-25 05:14:12 +01:00
|
|
|
|
|
|
|
/* Then schedule execution of the signal handling action on the
|
|
|
|
* recipient's thread. SMP related handling will be done in
|
|
|
|
* up_schedule_sigaction()
|
|
|
|
*/
|
|
|
|
|
|
|
|
up_schedule_sigaction(stcb, nxsig_deliver);
|
2016-02-14 15:17:46 +01:00
|
|
|
leave_critical_section(flags);
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sched_unlock();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/****************************************************************************
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* Name: nxsig_alloc_pendingsignal
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Allocate a pending signal list entry
|
|
|
|
*
|
2013-02-05 20:50:37 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
static FAR sigpendq_t *nxsig_alloc_pendingsignal(void)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR sigpendq_t *sigpend;
|
2016-02-14 15:17:46 +01:00
|
|
|
irqstate_t flags;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* Check if we were called from an interrupt handler. */
|
|
|
|
|
|
|
|
if (up_interrupt_context())
|
|
|
|
{
|
|
|
|
/* Try to get the pending signal structure from the free list */
|
|
|
|
|
2015-10-08 03:59:14 +02:00
|
|
|
sigpend = (FAR sigpendq_t *)sq_remfirst(&g_sigpendingsignal);
|
2011-08-07 14:58:54 +02:00
|
|
|
if (!sigpend)
|
|
|
|
{
|
|
|
|
/* If no pending signal structure is available in the free list,
|
|
|
|
* then try the special list of structures reserved for
|
|
|
|
* interrupt handlers
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2015-10-08 03:59:14 +02:00
|
|
|
sigpend = (FAR sigpendq_t *)sq_remfirst(&g_sigpendingirqsignal);
|
2011-08-07 14:58:54 +02:00
|
|
|
}
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If we were not called from an interrupt handler, then we are
|
2015-12-11 17:06:40 +01:00
|
|
|
* free to allocate pending action structures if necessary.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Try to get the pending signal structure from the free list */
|
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
flags = enter_critical_section();
|
2015-10-08 03:59:14 +02:00
|
|
|
sigpend = (FAR sigpendq_t *)sq_remfirst(&g_sigpendingsignal);
|
2016-02-14 15:17:46 +01:00
|
|
|
leave_critical_section(flags);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* Check if we got one. */
|
|
|
|
|
|
|
|
if (!sigpend)
|
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
/* No... Allocate the pending signal */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2023-08-28 09:39:47 +02:00
|
|
|
sigpend = kmm_malloc(sizeof(sigpendq_t));
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* Check if we got an allocated message */
|
|
|
|
|
|
|
|
if (sigpend)
|
|
|
|
{
|
|
|
|
sigpend->type = SIG_ALLOC_DYN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sigpend;
|
|
|
|
}
|
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/****************************************************************************
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* Name: nxsig_find_pendingsignal
|
2013-02-05 20:50:37 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Find a specified element in the pending signal list
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
static FAR sigpendq_t *
|
2023-08-21 05:03:56 +02:00
|
|
|
nxsig_find_pendingsignal(FAR struct task_group_s *group, int signo)
|
2013-02-05 20:50:37 +01:00
|
|
|
{
|
|
|
|
FAR sigpendq_t *sigpend = NULL;
|
2016-02-14 15:17:46 +01:00
|
|
|
irqstate_t flags;
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2016-02-18 16:21:43 +01:00
|
|
|
DEBUGASSERT(group != NULL);
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2023-08-21 05:03:56 +02:00
|
|
|
/* Determining whether a signal is reliable or unreliable */
|
|
|
|
|
|
|
|
if (SIGRTMIN <= signo && signo <= SIGRTMAX)
|
|
|
|
{
|
|
|
|
return sigpend;
|
|
|
|
}
|
|
|
|
|
2018-02-14 15:20:40 +01:00
|
|
|
/* Pending signals can be added from interrupt level. */
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
flags = enter_critical_section();
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2018-02-14 15:20:40 +01:00
|
|
|
/* Search the list for a action pending on this signal */
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2016-02-18 15:34:11 +01:00
|
|
|
for (sigpend = (FAR sigpendq_t *)group->tg_sigpendingq.head;
|
2014-04-12 21:28:22 +02:00
|
|
|
(sigpend && sigpend->info.si_signo != signo);
|
|
|
|
sigpend = sigpend->flink);
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
leave_critical_section(flags);
|
2013-02-05 20:50:37 +01:00
|
|
|
return sigpend;
|
|
|
|
}
|
|
|
|
|
2022-12-22 13:46:12 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: nxsig_dispatch_kernel_action
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static void nxsig_dispatch_kernel_action(FAR struct tcb_s *stcb,
|
|
|
|
FAR siginfo_t *info)
|
|
|
|
{
|
|
|
|
FAR struct task_group_s *group = stcb->group;
|
|
|
|
FAR sigactq_t *sigact;
|
|
|
|
|
|
|
|
sigact = nxsig_find_action(group, info->si_signo);
|
|
|
|
if (sigact && (sigact->act.sa_flags & SA_KERNELHAND))
|
|
|
|
{
|
|
|
|
info->si_user = sigact->act.sa_user;
|
|
|
|
(sigact->act.sa_sigaction)(info->si_signo, info, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/****************************************************************************
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* Name: nxsig_add_pendingsignal
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2020-10-04 17:48:34 +02:00
|
|
|
* Add the specified signal to the signal pending list. NOTE: This
|
|
|
|
* function will queue only one entry for each pending signal. This
|
2012-07-14 21:30:31 +02:00
|
|
|
* was done intentionally so that a run-away sender cannot consume
|
|
|
|
* all of memory.
|
|
|
|
*
|
2013-02-05 20:50:37 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2018-08-24 14:58:30 +02:00
|
|
|
static void nxsig_add_pendingsignal(FAR struct tcb_s *stcb,
|
|
|
|
FAR siginfo_t *info)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2016-02-18 16:21:43 +01:00
|
|
|
FAR struct task_group_s *group;
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR sigpendq_t *sigpend;
|
2016-02-14 15:17:46 +01:00
|
|
|
irqstate_t flags;
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2016-02-18 16:21:43 +01:00
|
|
|
DEBUGASSERT(stcb != NULL && stcb->group != NULL);
|
|
|
|
group = stcb->group;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-18 16:21:43 +01:00
|
|
|
/* Check if the signal is already pending for the group */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
sigpend = nxsig_find_pendingsignal(group, info->si_signo);
|
2018-08-24 14:58:30 +02:00
|
|
|
if (sigpend != NULL)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
|
|
|
/* The signal is already pending... retain only one copy */
|
|
|
|
|
2007-02-21 22:55:16 +01:00
|
|
|
memcpy(&sigpend->info, info, sizeof(siginfo_t));
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|
|
|
|
|
2016-02-18 16:21:43 +01:00
|
|
|
/* No... There is nothing pending in the group for this signo */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Allocate a new pending signal entry */
|
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
sigpend = nxsig_alloc_pendingsignal();
|
2018-08-24 14:58:30 +02:00
|
|
|
if (sigpend != NULL)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
|
|
|
/* Put the signal information into the allocated structure */
|
|
|
|
|
2007-02-21 22:55:16 +01:00
|
|
|
memcpy(&sigpend->info, info, sizeof(siginfo_t));
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-18 16:21:43 +01:00
|
|
|
/* Add the structure to the group pending signal list */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
flags = enter_critical_section();
|
2016-02-18 15:34:11 +01:00
|
|
|
sq_addlast((FAR sq_entry_t *)sigpend, &group->tg_sigpendingq);
|
2016-02-14 15:17:46 +01:00
|
|
|
leave_critical_section(flags);
|
2022-12-22 13:46:12 +01:00
|
|
|
nxsig_dispatch_kernel_action(stcb, &sigpend->info);
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-24 14:58:30 +02:00
|
|
|
DEBUGASSERT(sigpend);
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Functions
|
2013-02-05 20:50:37 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/****************************************************************************
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* Name: nxsig_tcbdispatch
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2012-07-14 21:30:31 +02:00
|
|
|
* All signals received the task (whatever the source) go through this
|
2020-10-04 17:48:34 +02:00
|
|
|
* function to be processed. This function is responsible for:
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* - Determining if the signal is blocked.
|
|
|
|
* - Queuing and dispatching signal actions
|
|
|
|
* - Unblocking tasks that are waiting for signals
|
|
|
|
* - Queuing pending signals.
|
|
|
|
*
|
2013-02-05 20:50:37 +01:00
|
|
|
* This function will deliver the signal to the task associated with
|
2020-10-04 17:48:34 +02:00
|
|
|
* the specified TCB. This function should *not* typically be used
|
2013-02-05 20:50:37 +01:00
|
|
|
* to dispatch signals since it will *not* follow the group signal
|
|
|
|
* deliver algorithms.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Returns 0 (OK) on success or a negated errno value on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2022-11-01 02:52:11 +01:00
|
|
|
FAR struct tcb_s *rtcb = this_task();
|
2016-02-14 15:17:46 +01:00
|
|
|
irqstate_t flags;
|
2020-04-29 18:53:36 +02:00
|
|
|
int masked;
|
2013-02-05 20:50:37 +01:00
|
|
|
int ret = OK;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2023-03-23 21:36:14 +01:00
|
|
|
sinfo("TCB=%p pid=%d signo=%d code=%d value=%d masked=%s\n",
|
2023-03-13 11:17:42 +01:00
|
|
|
stcb, stcb->pid, info->si_signo, info->si_code,
|
2023-03-23 21:36:14 +01:00
|
|
|
info->si_value.sival_int,
|
|
|
|
sigismember(&stcb->sigprocmask, info->si_signo) == 1 ? "YES" : "NO");
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-18 21:56:48 +01:00
|
|
|
DEBUGASSERT(stcb != NULL && info != NULL);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2023-05-24 02:39:40 +02:00
|
|
|
/* Return ESRCH when thread was in exit processing */
|
|
|
|
|
|
|
|
if ((stcb->flags & TCB_FLAG_EXIT_PROCESSING) != 0)
|
|
|
|
{
|
|
|
|
return -ESRCH;
|
|
|
|
}
|
|
|
|
|
2020-03-09 11:38:21 +01:00
|
|
|
/* Don't actually send a signal for signo 0. */
|
|
|
|
|
|
|
|
if (info->si_signo == 0)
|
|
|
|
{
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2019-11-30 21:08:47 +01:00
|
|
|
/************************** MASKED SIGNAL ACTIONS *************************/
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2020-04-29 18:53:36 +02:00
|
|
|
masked = nxsig_ismember(&stcb->sigprocmask, info->si_signo);
|
2019-11-29 15:11:55 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_LIB_SYSCALL
|
|
|
|
/* Check if the signal is masked OR if the signal is received while we are
|
2019-11-28 19:47:36 +01:00
|
|
|
* processing a system call -- in either case, it will be added to the
|
2020-10-04 17:48:34 +02:00
|
|
|
* list of pending signals. Unmasked user signal actions will be deferred
|
2019-11-29 15:11:55 +01:00
|
|
|
* while we process the system call.
|
2019-11-29 17:01:42 +01:00
|
|
|
*
|
2019-11-30 21:08:47 +01:00
|
|
|
* If a thread calls a blocking system call, the thread will still be
|
|
|
|
* unblocked when the signal occurs (see OTHER SIGNAL HANDLING below), but
|
|
|
|
* any associated user signal action will be deferred until the system
|
2020-10-04 17:48:34 +02:00
|
|
|
* call returns. For example, if the application calls sem_wait(), the
|
2019-11-30 21:08:47 +01:00
|
|
|
* following would occur:
|
|
|
|
*
|
|
|
|
* 1. System call entry logic will block user signal handling and call
|
|
|
|
* sem_wait() in kernel mode.
|
|
|
|
* 2. sem_wait() will block,
|
|
|
|
* 3. The receipt of the signal will cause any signal action to pend
|
|
|
|
* but will unblock sem_wait(),
|
|
|
|
* 4. The sem_wait() system call will awaken and return EINTR,
|
|
|
|
* 5. The pending signal action will occur after the sem_wait() system
|
|
|
|
* call returns to user mode.
|
|
|
|
*
|
2019-11-29 17:01:42 +01:00
|
|
|
* Syscall handlers (and logic-in-general within the OS) should not use
|
|
|
|
* signal handlers.
|
2019-11-29 15:11:55 +01:00
|
|
|
*/
|
|
|
|
|
2020-04-29 18:53:36 +02:00
|
|
|
if ((masked == 1) || (stcb->flags & TCB_FLAG_SYSCALL) != 0)
|
2019-11-29 15:11:55 +01:00
|
|
|
#else
|
2020-10-04 17:48:34 +02:00
|
|
|
/* Check if the signal is masked. In that case, it will be added to the
|
2019-11-28 19:47:36 +01:00
|
|
|
* list of pending signals.
|
2013-02-05 20:50:37 +01:00
|
|
|
*/
|
2007-03-19 17:38:47 +01:00
|
|
|
|
2020-04-29 18:53:36 +02:00
|
|
|
if (masked == 1)
|
2019-11-29 15:11:55 +01:00
|
|
|
#endif
|
2013-02-05 20:50:37 +01:00
|
|
|
{
|
2020-10-04 17:48:34 +02:00
|
|
|
/* Check if the task is waiting for this pending signal. If so, then
|
|
|
|
* unblock it. This must be performed in a critical section because
|
|
|
|
* signals can be queued from the interrupt level.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
flags = enter_critical_section();
|
2013-02-05 20:50:37 +01:00
|
|
|
if (stcb->task_state == TSTATE_WAIT_SIG &&
|
2021-02-15 07:29:01 +01:00
|
|
|
(masked == 0 ||
|
|
|
|
nxsig_ismember(&stcb->sigwaitmask, info->si_signo)))
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2013-02-05 20:50:37 +01:00
|
|
|
memcpy(&stcb->sigunbinfo, info, sizeof(siginfo_t));
|
2023-03-23 21:36:14 +01:00
|
|
|
sigemptyset(&stcb->sigwaitmask);
|
2022-09-06 10:33:58 +02:00
|
|
|
|
|
|
|
if (WDOG_ISACTIVE(&stcb->waitdog))
|
|
|
|
{
|
|
|
|
wd_cancel(&stcb->waitdog);
|
|
|
|
}
|
|
|
|
|
2022-11-01 02:52:11 +01:00
|
|
|
/* Remove the task from waitting list */
|
|
|
|
|
|
|
|
dq_rem((FAR dq_entry_t *)stcb, &g_waitingforsignal);
|
|
|
|
|
|
|
|
/* Add the task to ready-to-run task list and
|
|
|
|
* perform the context switch if one is needed
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (nxsched_add_readytorun(stcb))
|
|
|
|
{
|
2022-11-15 09:52:40 +01:00
|
|
|
up_switch_context(stcb, rtcb);
|
2022-11-01 02:52:11 +01:00
|
|
|
}
|
2023-03-08 08:04:33 +01:00
|
|
|
|
|
|
|
leave_critical_section(flags);
|
2023-03-13 11:17:42 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_LIB_SYSCALL
|
|
|
|
/* Must also add signal action if in system call */
|
|
|
|
|
|
|
|
if (masked == 0)
|
|
|
|
{
|
|
|
|
nxsig_add_pendingsignal(stcb, info);
|
|
|
|
}
|
|
|
|
#endif
|
2013-02-05 20:50:37 +01:00
|
|
|
}
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2023-03-08 08:04:33 +01:00
|
|
|
/* Its not one we are waiting for... Add it to the list of pending
|
|
|
|
* signals.
|
|
|
|
*/
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
leave_critical_section(flags);
|
|
|
|
nxsig_add_pendingsignal(stcb, info);
|
|
|
|
}
|
2013-02-05 20:50:37 +01:00
|
|
|
}
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2019-11-30 21:08:47 +01:00
|
|
|
/************************* UNMASKED SIGNAL ACTIONS ************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Queue any sigaction's requested by this task. */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
ret = nxsig_queue_action(stcb, info);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-11-20 14:57:18 +01:00
|
|
|
/* Deliver of the signal must be performed in a critical section */
|
|
|
|
|
|
|
|
flags = enter_critical_section();
|
|
|
|
|
2020-10-04 17:48:34 +02:00
|
|
|
/* Check if the task is waiting for an unmasked signal. If so, then
|
2013-02-05 20:50:37 +01:00
|
|
|
* unblock it. This must be performed in a critical section because
|
|
|
|
* signals can be queued from the interrupt level.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
if (stcb->task_state == TSTATE_WAIT_SIG)
|
|
|
|
{
|
|
|
|
memcpy(&stcb->sigunbinfo, info, sizeof(siginfo_t));
|
2023-03-23 21:36:14 +01:00
|
|
|
sigemptyset(&stcb->sigwaitmask);
|
2022-09-06 10:33:58 +02:00
|
|
|
|
|
|
|
if (WDOG_ISACTIVE(&stcb->waitdog))
|
|
|
|
{
|
|
|
|
wd_cancel(&stcb->waitdog);
|
|
|
|
}
|
|
|
|
|
2022-11-01 02:52:11 +01:00
|
|
|
/* Remove the task from waitting list */
|
|
|
|
|
|
|
|
dq_rem((FAR dq_entry_t *)stcb, &g_waitingforsignal);
|
|
|
|
|
|
|
|
/* Add the task to ready-to-run task list and
|
|
|
|
* perform the context switch if one is needed
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (nxsched_add_readytorun(stcb))
|
|
|
|
{
|
2022-11-15 09:52:40 +01:00
|
|
|
up_switch_context(stcb, rtcb);
|
2022-11-01 02:52:11 +01:00
|
|
|
}
|
2013-02-05 20:50:37 +01:00
|
|
|
}
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-14 15:17:46 +01:00
|
|
|
leave_critical_section(flags);
|
2013-02-05 20:50:37 +01:00
|
|
|
|
|
|
|
/* If the task neither was waiting for the signal nor had a signal
|
|
|
|
* handler attached to the signal, then the default action is
|
|
|
|
* simply to ignore the signal
|
|
|
|
*/
|
2019-11-28 19:47:36 +01:00
|
|
|
}
|
|
|
|
|
2019-11-30 22:34:00 +01:00
|
|
|
/************************* OTHER SIGNAL HANDLING **************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2020-10-04 17:48:34 +02:00
|
|
|
/* Performed only if the signal is unmasked. These actions also must
|
2019-11-28 19:47:36 +01:00
|
|
|
* happen within a system call.
|
|
|
|
*/
|
2007-03-19 17:38:47 +01:00
|
|
|
|
2020-04-29 18:53:36 +02:00
|
|
|
if (masked == 0)
|
2019-11-28 19:47:36 +01:00
|
|
|
{
|
2022-10-20 18:14:37 +02:00
|
|
|
flags = enter_critical_section();
|
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/* If the task is blocked waiting for a semaphore, then that task must
|
|
|
|
* be unblocked when a signal is received.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
if (stcb->task_state == TSTATE_WAIT_SEM)
|
|
|
|
{
|
2017-10-09 17:06:46 +02:00
|
|
|
nxsem_wait_irq(stcb, EINTR);
|
2013-02-05 20:50:37 +01:00
|
|
|
}
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2022-11-16 11:20:31 +01:00
|
|
|
#if !defined(CONFIG_DISABLE_MQUEUE) || !defined(CONFIG_DISABLE_MQUEUE_SYSV)
|
2013-02-05 20:50:37 +01:00
|
|
|
/* If the task is blocked waiting on a message queue, then that task
|
|
|
|
* must be unblocked when a signal is received.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
if (stcb->task_state == TSTATE_WAIT_MQNOTEMPTY ||
|
|
|
|
stcb->task_state == TSTATE_WAIT_MQNOTFULL)
|
|
|
|
{
|
2017-10-09 17:06:46 +02:00
|
|
|
nxmq_wait_irq(stcb, EINTR);
|
2013-02-05 20:50:37 +01:00
|
|
|
}
|
2007-03-28 16:48:42 +02:00
|
|
|
#endif
|
2018-08-30 18:27:18 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
2020-10-29 05:53:41 +01:00
|
|
|
/* If the task was stopped by SIGSTOP or SIGTSTP, then unblock the task
|
2018-08-30 18:27:18 +02:00
|
|
|
* if SIGCONT is received.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (stcb->task_state == TSTATE_TASK_STOPPED &&
|
|
|
|
info->si_signo == SIGCONT)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_GROUP_MEMBERS
|
|
|
|
group_continue(stcb);
|
|
|
|
#else
|
2022-11-01 02:52:11 +01:00
|
|
|
/* Remove the task from waitting list */
|
|
|
|
|
|
|
|
dq_rem((FAR dq_entry_t *)stcb, &g_stoppedtasks);
|
|
|
|
|
|
|
|
/* Add the task to ready-to-run task list and
|
|
|
|
* perform the context switch if one is needed
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (nxsched_add_readytorun(stcb))
|
|
|
|
{
|
2022-11-15 09:52:40 +01:00
|
|
|
up_switch_context(stcb, rtcb);
|
2022-11-01 02:52:11 +01:00
|
|
|
}
|
2018-08-30 18:27:18 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
2022-10-20 18:14:37 +02:00
|
|
|
|
|
|
|
leave_critical_section(flags);
|
2013-02-05 20:50:37 +01:00
|
|
|
}
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2020-04-29 18:53:36 +02:00
|
|
|
/* In case nxsig_ismember failed due to an invalid signal number */
|
|
|
|
|
|
|
|
if (masked < 0)
|
|
|
|
{
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
return ret;
|
|
|
|
}
|
2013-02-05 20:50:37 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* Name: nxsig_dispatch
|
2013-02-05 20:50:37 +01:00
|
|
|
*
|
|
|
|
* Description:
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* This is the front-end for nxsig_tcbdispatch that should be typically
|
2020-10-04 17:48:34 +02:00
|
|
|
* be used to dispatch a signal. If HAVE_GROUP_MEMBERS is defined,
|
2018-02-14 15:36:34 +01:00
|
|
|
* then function will follow the group signal delivery algorithms:
|
2013-02-05 20:50:37 +01:00
|
|
|
*
|
|
|
|
* This front-end does the following things before calling
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* nxsig_tcbdispatch.
|
2013-02-05 20:50:37 +01:00
|
|
|
*
|
|
|
|
* With HAVE_GROUP_MEMBERS defined:
|
|
|
|
* - Get the TCB associated with the pid.
|
|
|
|
* - If the TCB was found, get the group from the TCB.
|
|
|
|
* - If the PID has already exited, lookup the group that that was
|
|
|
|
* started by this task.
|
|
|
|
* - Use the group to pick the TCB to receive the signal
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* - Call nxsig_tcbdispatch with the TCB
|
2013-02-05 20:50:37 +01:00
|
|
|
*
|
|
|
|
* With HAVE_GROUP_MEMBERS *not* defined
|
|
|
|
* - Get the TCB associated with the pid.
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
* - Call nxsig_tcbdispatch with the TCB
|
2013-02-05 20:50:37 +01:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Returns 0 (OK) on success or a negated errno value on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
int nxsig_dispatch(pid_t pid, FAR siginfo_t *info)
|
2013-02-05 20:50:37 +01:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GROUP_MEMBERS
|
|
|
|
FAR struct tcb_s *stcb;
|
|
|
|
FAR struct task_group_s *group;
|
|
|
|
|
|
|
|
/* Get the TCB associated with the pid */
|
|
|
|
|
2020-05-09 16:04:45 +02:00
|
|
|
stcb = nxsched_get_tcb(pid);
|
2016-02-18 21:56:48 +01:00
|
|
|
if (stcb != NULL)
|
2013-02-05 20:50:37 +01:00
|
|
|
{
|
2020-10-04 17:48:34 +02:00
|
|
|
/* The task/thread associated with this PID is still active. Get its
|
2013-02-05 20:50:37 +01:00
|
|
|
* task group.
|
|
|
|
*/
|
|
|
|
|
|
|
|
group = stcb->group;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-04 17:48:34 +02:00
|
|
|
/* The task/thread associated with this PID has exited. In the normal
|
2013-02-05 20:50:37 +01:00
|
|
|
* usage model, the PID should correspond to the PID of the task that
|
2020-10-04 17:48:34 +02:00
|
|
|
* created the task group. Try looking it up.
|
2013-02-05 20:50:37 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
group = group_findbypid(pid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Did we locate the group? */
|
|
|
|
|
2016-02-18 21:56:48 +01:00
|
|
|
if (group != NULL)
|
2013-02-05 20:50:37 +01:00
|
|
|
{
|
|
|
|
/* Yes.. call group_signal() to send the signal to the correct group
|
|
|
|
* member.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return group_signal(group, info);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -ESRCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
FAR struct tcb_s *stcb;
|
|
|
|
|
|
|
|
/* Get the TCB associated with the pid */
|
|
|
|
|
2020-05-09 16:04:45 +02:00
|
|
|
stcb = nxsched_get_tcb(pid);
|
2016-02-18 21:56:48 +01:00
|
|
|
if (stcb == NULL)
|
2013-02-05 20:50:37 +01:00
|
|
|
{
|
|
|
|
return -ESRCH;
|
|
|
|
}
|
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
return nxsig_tcbdispatch(stcb, info);
|
2013-02-05 20:50:37 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|