sigaction.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Copyright (C) 1991-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #ifndef _BITS_SIGACTION_H
  15. #define _BITS_SIGACTION_H 1
  16. #ifndef _SIGNAL_H
  17. # error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
  18. #endif
  19. /* These definitions match those used by the 4.4 BSD kernel.
  20. If the operating system has a `sigaction' system call that correctly
  21. implements the POSIX.1 behavior, there should be a system-dependent
  22. version of this file that defines `struct sigaction' and the `SA_*'
  23. constants appropriately. */
  24. /* Structure describing the action to be taken when a signal arrives. */
  25. struct sigaction
  26. {
  27. /* Signal handler. */
  28. #if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
  29. union
  30. {
  31. /* Used if SA_SIGINFO is not set. */
  32. __sighandler_t sa_handler;
  33. /* Used if SA_SIGINFO is set. */
  34. void (*sa_sigaction) (int, siginfo_t *, void *);
  35. }
  36. __sigaction_handler;
  37. # define sa_handler __sigaction_handler.sa_handler
  38. # define sa_sigaction __sigaction_handler.sa_sigaction
  39. #else
  40. __sighandler_t sa_handler;
  41. #endif
  42. /* Additional set of signals to be blocked. */
  43. __sigset_t sa_mask;
  44. /* Special flags. */
  45. int sa_flags;
  46. };
  47. /* Bits in `sa_flags'. */
  48. #if defined __USE_XOPEN_EXTENDED || defined __USE_MISC
  49. # define SA_ONSTACK 0x0001 /* Take signal on signal stack. */
  50. #endif
  51. #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
  52. # define SA_RESTART 0x0002 /* Restart syscall on signal return. */
  53. # define SA_NODEFER 0x0010 /* Don't automatically block the signal when
  54. its handler is being executed. */
  55. # define SA_RESETHAND 0x0004 /* Reset to SIG_DFL on entry to handler. */
  56. #endif
  57. #define SA_NOCLDSTOP 0x0008 /* Don't send SIGCHLD when children stop. */
  58. #define SA_SIGINFO 0x0040 /* Signal handler with SA_SIGINFO args */
  59. #ifdef __USE_MISC
  60. # define SA_INTERRUPT 0 /* Historical no-op ("not SA_RESTART"). */
  61. /* Some aliases for the SA_ constants. */
  62. # define SA_NOMASK SA_NODEFER
  63. # define SA_ONESHOT SA_RESETHAND
  64. # define SA_STACK SA_ONSTACK
  65. #endif
  66. /* Values for the HOW argument to `sigprocmask'. */
  67. #define SIG_BLOCK 1 /* Block signals. */
  68. #define SIG_UNBLOCK 2 /* Unblock signals. */
  69. #define SIG_SETMASK 3 /* Set the set of blocked signals. */
  70. #endif