signal.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* The <signal.h> header defines all the ANSI and POSIX signals.
  2. * MINIX supports all the signals required by POSIX. They are defined below.
  3. * Some additional signals are also supported.
  4. */
  5. #ifndef _SIGNAL_H
  6. #define _SIGNAL_H
  7. /* Here are types that are closely associated with signal handling. */
  8. typedef int sig_atomic_t;
  9. #ifdef _POSIX_SOURCE
  10. typedef unsigned short sigset_t;
  11. #endif
  12. #define _NSIG 16 /* number of signals used */
  13. #define SIGHUP 1 /* hangup */
  14. #define SIGINT 2 /* interrupt (DEL) */
  15. #define SIGQUIT 3 /* quit (ASCII FS) */
  16. #define SIGILL 4 /* illegal instruction */
  17. #define SIGTRAP 5 /* trace trap (not reset when caught) */
  18. #define SIGABRT 6 /* IOT instruction */
  19. #define SIGIOT 6 /* SIGABRT for people who speak PDP-11 */
  20. #define SIGUNUSED 7 /* spare code */
  21. #define SIGFPE 8 /* floating point exception */
  22. #define SIGKILL 9 /* kill (cannot be caught or ignored) */
  23. #define SIGUSR1 10 /* user defined signal # 1 */
  24. #define SIGSEGV 11 /* segmentation violation */
  25. #define SIGUSR2 12 /* user defined signal # 2 */
  26. #define SIGSYS 12 /* the usual UNIX name for this signal num */
  27. #define SIGPIPE 13 /* write on a pipe with no one to read it */
  28. #define SIGALRM 14 /* alarm clock */
  29. #define SIGTERM 15 /* software termination signal from kill */
  30. #define SIGSTKFLT 16 /* used by kernel to indicate stack fault */
  31. #define SIGEMT 7 /* obsolete */
  32. #define SIGBUS 10 /* obsolete */
  33. /* POSIX requires the following signals to be defined, even if they are
  34. * not supported. Here are the definitions, but they are not supported.
  35. */
  36. #define SIGCHLD 17 /* child process terminated or stopped */
  37. #define SIGCONT 18 /* continue if stopped */
  38. #define SIGSTOP 19 /* stop signal */
  39. #define SIGTSTP 20 /* interactive stop signal */
  40. #define SIGTTIN 21 /* background process wants to read */
  41. #define SIGTTOU 22 /* background process wants to write */
  42. #ifdef _POSIX_SOURCE
  43. #define SA_NOCLDSTOP 1 /* signal parent if child stops */
  44. #endif /* _POSIX_SOURCE */
  45. /* POSIX requires these values for use on system calls involving signals. */
  46. #define SIG_BLOCK 0 /* for blocking signals */
  47. #define SIG_UNBLOCK 1 /* for unblocking signals */
  48. #define SIG_SETMASK 2 /* for setting the signal mask */
  49. #ifndef _ANSI_H
  50. #include <ansi.h>
  51. #endif
  52. /* Macros used as function pointers and one awful prototype. */
  53. #if _ANSI
  54. #define SIG_DFL ((void (*)(int))0) /* default signal handling */
  55. #define SIG_IGN ((void (*)(int))1) /* ignore signal */
  56. #define SIG_ERR ((void (*)(int))-1)
  57. void (*signal(int _sig, void (*_func)(int)))(int);
  58. #ifdef _POSIX_SOURCE
  59. struct sigaction {
  60. void (*sa_handler)(int); /* SIG_DFL, SIG_IGN, or pointer to function */
  61. sigset_t sa_mask; /* signals to be blocked during handler */
  62. int sa_flags; /* special flags */
  63. };
  64. #endif
  65. #else /* !_ANSI */
  66. #define SIG_DFL ((void (*)())0) /* default signal handling */
  67. #define SIG_IGN ((void (*)())1) /* ignore signal */
  68. #define SIG_ERR ((void (*)())-1)
  69. void (*signal()) ();
  70. #ifdef _POSIX_SOURCE /* otherwise sigset_t is not defined */
  71. struct sigaction {
  72. void (*sa_handler)(); /* SIG_DFL, SIG_IGN, or pointer to function */
  73. sigset_t sa_mask; /* signals to be blocked during handler */
  74. int sa_flags; /* special flags */
  75. };
  76. #endif
  77. #endif /* _ANSI */
  78. /* Function Prototypes. */
  79. _PROTOTYPE( int raise, (int _sig) );
  80. #ifdef _POSIX_SOURCE
  81. _PROTOTYPE( int kill, (pid_t _pid, int _sig) );
  82. _PROTOTYPE( int sigaddset, (sigset_t *_set) );
  83. _PROTOTYPE( int sigdelset, (sigset_t *_set) );
  84. _PROTOTYPE( int sigemptyset, (sigset_t *_set) );
  85. _PROTOTYPE( int sigfillset, (sigset_t *_set) );
  86. _PROTOTYPE( int sigismember, (sigset_t *_set, int _signo) );
  87. _PROTOTYPE( int sigpending, (sigset_t *set) );
  88. _PROTOTYPE( int sigprocmask, (int _how, sigset_t *_set, sigset_t *_oset));
  89. _PROTOTYPE( int sigsuspend, (sigset_t *_sigmask) );
  90. _PROTOTYPE( int sigaction,
  91. (int _sig, struct sigaction *_a, struct sigaction *_oact) );
  92. #endif
  93. #endif /* _SIGNAL_H */