1
0

posix_signal.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * File : signals.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2017, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2017/10/1 Bernard The first version
  23. */
  24. #ifndef POSIX_SIGNAL_H__
  25. #define POSIX_SIGNAL_H__
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #include <rtthread.h>
  30. enum rt_signal_value{
  31. SIG1 = SIGHUP,
  32. SIG2 = SIGINT,
  33. SIG3 = SIGQUIT,
  34. SIG4 = SIGILL,
  35. SIG5 = SIGTRAP,
  36. SIG6 = SIGABRT,
  37. SIG7 = SIGEMT,
  38. SIG8 = SIGFPE,
  39. SIG9 = SIGKILL,
  40. SIG10 = SIGBUS,
  41. SIG11 = SIGSEGV,
  42. SIG12 = SIGSYS,
  43. SIG13 = SIGPIPE,
  44. SIG14 = SIGALRM,
  45. SIG15 = SIGTERM,
  46. SIG16 = SIGURG,
  47. SIG17 = SIGSTOP,
  48. SIG18 = SIGTSTP,
  49. SIG19 = SIGCONT,
  50. SIG20 = SIGCHLD,
  51. SIG21 = SIGTTIN,
  52. SIG22 = SIGTTOU,
  53. SIG23 = SIGPOLL,
  54. SIG24 = 24, // SIGXCPU,
  55. SIG25 = 25, // SIGXFSZ,
  56. SIG26 = 26, // SIGVTALRM,
  57. SIG27 = 27, // SIGPROF,
  58. SIG28 = SIGWINCH,
  59. SIG29 = 29, // SIGLOST,
  60. SIG30 = SIGUSR1,
  61. SIG31 = SIGUSR2,
  62. SIGRT_MIN = 27, // SIGRTMIN,
  63. SIGRT_MAX = 31, // SIGRTMAX,
  64. SIGMAX = NSIG,
  65. };
  66. /*
  67. The structure definitions on newlib:
  68. typedef void (*_sig_func_ptr)(int);
  69. struct sigaction
  70. {
  71. _sig_func_ptr sa_handler;
  72. sigset_t sa_mask;
  73. int sa_flags;
  74. };
  75. typedef int sig_atomic_t;
  76. typedef _sig_func_ptr sig_t;
  77. typedef _sig_func_ptr sighandler_t;
  78. When enable POSIX_REALTIME_SIGNALS/POSIX_THREADS:
  79. union sigval {
  80. int sival_int;
  81. void *sival_ptr;
  82. };
  83. struct sigevent {
  84. int sigev_notify;
  85. int sigev_signo;
  86. union sigval sigev_value;
  87. void (*sigev_notify_function)( union sigval );
  88. pthread_attr_t *sigev_notify_attributes;
  89. };
  90. typedef struct {
  91. int si_signo;
  92. int si_code;
  93. union sigval si_value;
  94. } siginfo_t;
  95. */
  96. rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler);
  97. void rt_signal_mask(int signo);
  98. void rt_signal_unmask(int signo);
  99. int rt_thread_kill(rt_thread_t tid, int sig);
  100. int rt_system_signal_init(void);
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif