signal.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /* $OpenBSD: signal.h,v 1.26 2013/04/29 17:06:20 matthew Exp $ */
  2. /* $NetBSD: signal.h,v 1.21 1996/02/09 18:25:32 christos Exp $ */
  3. /*
  4. * Copyright (c) 1982, 1986, 1989, 1991, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. * (c) UNIX System Laboratories, Inc.
  7. * All or some portions of this file are derived from material licensed
  8. * to the University of California by American Telephone and Telegraph
  9. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  10. * the permission of UNIX System Laboratories, Inc.
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. * 1. Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright
  18. * notice, this list of conditions and the following disclaimer in the
  19. * documentation and/or other materials provided with the distribution.
  20. * 3. Neither the name of the University nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  25. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. * SUCH DAMAGE.
  35. *
  36. * @(#)signal.h 8.2 (Berkeley) 1/21/94
  37. */
  38. #ifndef _SYS_SIGNAL_H_
  39. #define _SYS_SIGNAL_H_
  40. #include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */
  41. #define _NSIG 33 /* counting 0 (mask is 1-32) */
  42. #if __BSD_VISIBLE
  43. #define NSIG _NSIG
  44. #endif
  45. #define SIGHUP 1 /* hangup */
  46. #define SIGINT 2 /* interrupt */
  47. #define SIGQUIT 3 /* quit */
  48. #define SIGILL 4 /* illegal instruction (not reset when caught) */
  49. #define SIGTRAP 5 /* trace trap (not reset when caught) */
  50. #define SIGABRT 6 /* abort() */
  51. #if __BSD_VISIBLE
  52. #define SIGIOT SIGABRT /* compatibility */
  53. #define SIGEMT 7 /* EMT instruction */
  54. #endif
  55. #define SIGFPE 8 /* floating point exception */
  56. #define SIGKILL 9 /* kill (cannot be caught or ignored) */
  57. #define SIGBUS 10 /* bus error */
  58. #define SIGSEGV 11 /* segmentation violation */
  59. #define SIGSYS 12 /* bad argument to system call */
  60. #define SIGPIPE 13 /* write on a pipe with no one to read it */
  61. #define SIGALRM 14 /* alarm clock */
  62. #define SIGTERM 15 /* software termination signal from kill */
  63. #define SIGURG 16 /* urgent condition on IO channel */
  64. #define SIGSTOP 17 /* sendable stop signal not from tty */
  65. #define SIGTSTP 18 /* stop signal from tty */
  66. #define SIGCONT 19 /* continue a stopped process */
  67. #define SIGCHLD 20 /* to parent on child stop or exit */
  68. #define SIGTTIN 21 /* to readers pgrp upon background tty read */
  69. #define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
  70. #if __BSD_VISIBLE
  71. #define SIGIO 23 /* input/output possible signal */
  72. #endif
  73. #define SIGXCPU 24 /* exceeded CPU time limit */
  74. #define SIGXFSZ 25 /* exceeded file size limit */
  75. #define SIGVTALRM 26 /* virtual time alarm */
  76. #define SIGPROF 27 /* profiling time alarm */
  77. #if __BSD_VISIBLE
  78. #define SIGWINCH 28 /* window size changes */
  79. #define SIGINFO 29 /* information request */
  80. #endif
  81. #define SIGUSR1 30 /* user defined signal 1 */
  82. #define SIGUSR2 31 /* user defined signal 2 */
  83. #if __BSD_VISIBLE
  84. #define SIGTHR 32 /* thread library AST */
  85. #endif
  86. /*
  87. * Language spec says we must list exactly one parameter, even though we
  88. * actually supply three. Ugh!
  89. */
  90. #define SIG_DFL (void (*)(int))0
  91. #define SIG_IGN (void (*)(int))1
  92. #define SIG_ERR (void (*)(int))-1
  93. #if __POSIX_VISIBLE || __XPG_VISIBLE
  94. #ifndef _SIGSET_T_DEFINED_
  95. #define _SIGSET_T_DEFINED_
  96. typedef unsigned int sigset_t;
  97. #endif
  98. #include <sys/siginfo.h>
  99. /*
  100. * Signal vector "template" used in sigaction call.
  101. */
  102. struct sigaction {
  103. union { /* signal handler */
  104. void (*__sa_handler)(int);
  105. void (*__sa_sigaction)(int, siginfo_t *, void *);
  106. } __sigaction_u;
  107. sigset_t sa_mask; /* signal mask to apply */
  108. int sa_flags; /* see signal options below */
  109. };
  110. /* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */
  111. #define sa_handler __sigaction_u.__sa_handler
  112. #define sa_sigaction __sigaction_u.__sa_sigaction
  113. #if __XPG_VISIBLE >= 500
  114. #define SA_ONSTACK 0x0001 /* take signal on signal stack */
  115. #define SA_RESTART 0x0002 /* restart system on signal return */
  116. #define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */
  117. #define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */
  118. #define SA_NOCLDWAIT 0x0020 /* don't create zombies (assign to pid 1) */
  119. #endif /* __XPG_VISIBLE >= 500 */
  120. #define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
  121. #if __POSIX_VISIBLE >= 199309 || __XPG_VISIBLE >= 500
  122. #define SA_SIGINFO 0x0040 /* generate siginfo_t */
  123. #endif
  124. /*
  125. * Flags for sigprocmask:
  126. */
  127. #define SIG_BLOCK 1 /* block specified signal set */
  128. #define SIG_UNBLOCK 2 /* unblock specified signal set */
  129. #define SIG_SETMASK 3 /* set specified signal set */
  130. #endif /* __POSIX_VISIBLE || __XPG_VISIBLE */
  131. #if __BSD_VISIBLE
  132. typedef void (*sig_t)(int); /* type of signal function */
  133. /*
  134. * 4.3 compatibility:
  135. * Signal vector "template" used in sigvec call.
  136. */
  137. struct sigvec {
  138. void (*sv_handler)(int); /* signal handler */
  139. int sv_mask; /* signal mask to apply */
  140. int sv_flags; /* see signal options below */
  141. };
  142. #define SV_ONSTACK SA_ONSTACK
  143. #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */
  144. #define SV_RESETHAND SA_RESETHAND
  145. #define sv_onstack sv_flags /* isn't compatibility wonderful! */
  146. /*
  147. * Macro for converting signal number to a mask suitable for
  148. * sigblock().
  149. */
  150. #define sigmask(m) (1U << ((m)-1))
  151. #define BADSIG SIG_ERR
  152. #endif /* __BSD_VISIBLE */
  153. #if __BSD_VISIBLE || __XPG_VISIBLE >= 420
  154. /*
  155. * Structure used in sigaltstack call.
  156. */
  157. typedef struct sigaltstack {
  158. void *ss_sp; /* signal stack base */
  159. size_t ss_size; /* signal stack length */
  160. int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
  161. } stack_t;
  162. #define SS_ONSTACK 0x0001 /* take signals on alternate stack */
  163. #define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */
  164. #define MINSIGSTKSZ 8192 /* minimum allowable stack */
  165. #define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
  166. typedef struct sigcontext ucontext_t;
  167. #endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
  168. #ifndef _KERNEL
  169. /*
  170. * For historical reasons; programs expect signal's return value to be
  171. * defined by <sys/signal.h>.
  172. */
  173. __BEGIN_DECLS
  174. void (*signal(int, void (*)(int)))(int);
  175. __END_DECLS
  176. #endif /* !_KERNEL */
  177. #endif /* !_SYS_SIGNAL_H_ */