signal.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * signal.h
  3. *
  4. * A way to set handlers for exceptional conditions (also known as signals).
  5. *
  6. * This file is part of the Mingw32 package.
  7. *
  8. * Contributors:
  9. * Created by Colin Peters <[email protected]>
  10. *
  11. * THIS SOFTWARE IS NOT COPYRIGHTED
  12. *
  13. * This source code is offered for use in the public domain. You may
  14. * use, modify or distribute it freely.
  15. *
  16. * This code is distributed in the hope that it will be useful but
  17. * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  18. * DISCLAIMED. This includes but is not limited to warranties of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20. *
  21. * $Revision: 1.2 $
  22. * $Author: bellard $
  23. * $Date: 2005/04/17 13:14:29 $
  24. *
  25. */
  26. #ifndef _SIGNAL_H_
  27. #define _SIGNAL_H_
  28. /* All the headers include this file. */
  29. #include <_mingw.h>
  30. /*
  31. * The actual signal values. Using other values with signal
  32. * produces a SIG_ERR return value.
  33. *
  34. * NOTE: SIGINT is produced when the user presses Ctrl-C.
  35. * SIGILL has not been tested.
  36. * SIGFPE doesn't seem to work?
  37. * SIGSEGV does not catch writing to a NULL pointer (that shuts down
  38. * your app; can you say "segmentation violation core dump"?).
  39. * SIGTERM comes from what kind of termination request exactly?
  40. * SIGBREAK is indeed produced by pressing Ctrl-Break.
  41. * SIGABRT is produced by calling abort.
  42. * TODO: The above results may be related to not installing an appropriate
  43. * structured exception handling frame. Results may be better if I ever
  44. * manage to get the SEH stuff down.
  45. */
  46. #define SIGINT 2 /* Interactive attention */
  47. #define SIGILL 4 /* Illegal instruction */
  48. #define SIGFPE 8 /* Floating point error */
  49. #define SIGSEGV 11 /* Segmentation violation */
  50. #define SIGTERM 15 /* Termination request */
  51. #define SIGBREAK 21 /* Control-break */
  52. #define SIGABRT 22 /* Abnormal termination (abort) */
  53. #define NSIG 23 /* maximum signal number + 1 */
  54. #ifndef RC_INVOKED
  55. #ifndef _SIG_ATOMIC_T_DEFINED
  56. typedef int sig_atomic_t;
  57. #define _SIG_ATOMIC_T_DEFINED
  58. #endif
  59. /*
  60. * The prototypes (below) are the easy part. The hard part is figuring
  61. * out what signals are available and what numbers they are assigned
  62. * along with appropriate values of SIG_DFL and SIG_IGN.
  63. */
  64. /*
  65. * A pointer to a signal handler function. A signal handler takes a
  66. * single int, which is the signal it handles.
  67. */
  68. typedef void (*__p_sig_fn_t)(int);
  69. /*
  70. * These are special values of signal handler pointers which are
  71. * used to send a signal to the default handler (SIG_DFL), ignore
  72. * the signal (SIG_IGN), or indicate an error return (SIG_ERR).
  73. */
  74. #define SIG_DFL ((__p_sig_fn_t) 0)
  75. #define SIG_IGN ((__p_sig_fn_t) 1)
  76. #define SIG_ERR ((__p_sig_fn_t) -1)
  77. #ifdef __cplusplus
  78. extern "C" {
  79. #endif
  80. /*
  81. * Call signal to set the signal handler for signal sig to the
  82. * function pointed to by handler. Returns a pointer to the
  83. * previous handler, or SIG_ERR if an error occurs. Initially
  84. * unhandled signals defined above will return SIG_DFL.
  85. */
  86. __p_sig_fn_t signal(int, __p_sig_fn_t);
  87. /*
  88. * Raise the signal indicated by sig. Returns non-zero on success.
  89. */
  90. int raise (int);
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif /* Not RC_INVOKED */
  95. #endif /* Not _SIGNAL_H_ */