signal.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #ifndef __SIGNAL_H
  10. #define __SIGNAL_H
  11. #pragma lib "/$M/lib/ape/libap.a"
  12. typedef int sig_atomic_t;
  13. /*
  14. * We don't give arg types for signal handlers, in spite of ANSI requirement
  15. * that it be 'int' (the signal number), because some programs need an
  16. * additional context argument. So the real type of signal handlers is
  17. * void handler(int sig, char *, struct Ureg *)
  18. * where the char * is the Plan 9 message and Ureg is defined in <ureg.h>
  19. */
  20. #define SIG_DFL ((void (*)())0)
  21. #define SIG_ERR ((void (*)())-1)
  22. #define SIG_IGN ((void (*)())1)
  23. #define SIGHUP 1 /* hangup */
  24. #define SIGINT 2 /* interrupt */
  25. #define SIGQUIT 3 /* quit */
  26. #define SIGILL 4 /* illegal instruction (not reset when caught)*/
  27. #define SIGABRT 5 /* used by abort */
  28. #define SIGFPE 6 /* floating point exception */
  29. #define SIGKILL 7 /* kill (cannot be caught or ignored) */
  30. #define SIGSEGV 8 /* segmentation violation */
  31. #define SIGPIPE 9 /* write on a pipe with no one to read it */
  32. #define SIGALRM 10 /* alarm clock */
  33. #define SIGTERM 11 /* software termination signal from kill */
  34. #define SIGUSR1 12 /* user defined signal 1 */
  35. #define SIGUSR2 13 /* user defined signal 2 */
  36. #define SIGBUS 14 /* bus error */
  37. /* The following symbols must be defined, but the signals needn't be supported */
  38. #define SIGCHLD 15 /* child process terminated or stopped */
  39. #define SIGCONT 16 /* continue if stopped */
  40. #define SIGSTOP 17 /* stop */
  41. #define SIGTSTP 18 /* interactive stop */
  42. #define SIGTTIN 19 /* read from ctl tty by member of background */
  43. #define SIGTTOU 20 /* write to ctl tty by member of background */
  44. #ifdef _BSD_EXTENSION
  45. #define NSIG 21
  46. #endif
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50. extern void (*signal(int, void (*)()))();
  51. extern int raise(int);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #ifdef _POSIX_SOURCE
  56. typedef int32_t sigset_t;
  57. struct sigaction {
  58. void (*sa_handler)();
  59. sigset_t sa_mask;
  60. int sa_flags;
  61. };
  62. /* values for sa_flags */
  63. #define SA_NOCLDSTOP 1
  64. /* first argument to sigprocmask */
  65. #define SIG_BLOCK 1
  66. #define SIG_UNBLOCK 2
  67. #define SIG_SETMASK 3
  68. #ifdef __cplusplus
  69. extern "C" {
  70. #endif
  71. #ifdef __TYPES_H
  72. extern int kill(pid_t, int);
  73. #endif
  74. extern int sigemptyset(sigset_t *);
  75. extern int sigfillset(sigset_t *);
  76. extern int sigaddset(sigset_t *, int);
  77. extern int sigdelset(sigset_t *, int);
  78. extern int sigismember(const sigset_t *, int);
  79. extern int sigaction(int, const struct sigaction *, struct sigaction *);
  80. extern int sigprocmask(int, sigset_t *, sigset_t *);
  81. extern int sigpending(sigset_t *);
  82. extern int sigsuspend(const sigset_t *);
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif /* _POSIX_SOURCE */
  87. #endif /* __SIGNAL_H */