sig_removependingsignal.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /****************************************************************************
  2. * sched/signal/sig_removependingsignal.c
  3. *
  4. * Copyright (C) 2007, 2009, 2013-2014, 2016-2017 Gregory Nutt. All
  5. * rights reserved.
  6. * Author: Gregory Nutt <gnutt@nuttx.org>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. * 3. Neither the name NuttX nor the names of its contributors may be
  19. * used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ****************************************************************************/
  36. /****************************************************************************
  37. * Included Files
  38. ****************************************************************************/
  39. #include <nuttx/config.h>
  40. #include <unistd.h>
  41. #include <signal.h>
  42. #include <time.h>
  43. #include <assert.h>
  44. #include <debug.h>
  45. #include <sched.h>
  46. #include <nuttx/irq.h>
  47. #include <nuttx/arch.h>
  48. #include <nuttx/wdog.h>
  49. #include <nuttx/kmalloc.h>
  50. #include "signal/signal.h"
  51. /****************************************************************************
  52. * Public Functions
  53. ****************************************************************************/
  54. /****************************************************************************
  55. * Name: nxsig_remove_pendingsignal
  56. *
  57. * Description:
  58. * Remove the specified signal from the signal pending list
  59. *
  60. ****************************************************************************/
  61. FAR sigpendq_t *nxsig_remove_pendingsignal(FAR struct tcb_s *stcb, int signo)
  62. {
  63. FAR struct task_group_s *group = stcb->group;
  64. FAR sigpendq_t *currsig;
  65. FAR sigpendq_t *prevsig;
  66. irqstate_t flags;
  67. DEBUGASSERT(group);
  68. flags = enter_critical_section();
  69. for (prevsig = NULL, currsig = (FAR sigpendq_t *)group->tg_sigpendingq.head;
  70. (currsig && currsig->info.si_signo != signo);
  71. prevsig = currsig, currsig = currsig->flink);
  72. if (currsig)
  73. {
  74. if (prevsig)
  75. {
  76. sq_remafter((FAR sq_entry_t *)prevsig, &group->tg_sigpendingq);
  77. }
  78. else
  79. {
  80. sq_remfirst(&group->tg_sigpendingq);
  81. }
  82. }
  83. leave_critical_section(flags);
  84. return currsig;
  85. }