1
0

sigaction.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* The proper definitions for Linux's sigaction.
  17. Copyright (C) 1993-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _BITS_SIGACTION_H
  31. #define _BITS_SIGACTION_H 1
  32. #ifndef _SIGNAL_H
  33. # error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
  34. #endif
  35. /* Structure describing the action to be taken when a signal arrives. */
  36. struct sigaction
  37. {
  38. /* Signal handler. */
  39. #if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
  40. union
  41. {
  42. /* Used if SA_SIGINFO is not set. */
  43. __sighandler_t sa_handler;
  44. /* Used if SA_SIGINFO is set. */
  45. void (*sa_sigaction) (int, siginfo_t *, void *);
  46. }
  47. __sigaction_handler;
  48. # define sa_handler __sigaction_handler.sa_handler
  49. # define sa_sigaction __sigaction_handler.sa_sigaction
  50. #else
  51. __sighandler_t sa_handler;
  52. #endif
  53. /* Additional set of signals to be blocked. */
  54. __sigset_t sa_mask;
  55. /* Special flags. */
  56. int sa_flags;
  57. /* Restore handler. */
  58. void (*sa_restorer) (void);
  59. };
  60. /* Bits in `sa_flags'. */
  61. #define SA_NOCLDSTOP 1 /* Don't send SIGCHLD when children stop. */
  62. #define SA_NOCLDWAIT 2 /* Don't create zombie on child death. */
  63. #define SA_SIGINFO 4 /* Invoke signal-catching function with
  64. three arguments instead of one. */
  65. #if defined __USE_XOPEN_EXTENDED || defined __USE_MISC
  66. # define SA_ONSTACK 0x08000000 /* Use signal stack by using `sa_restorer'. */
  67. #endif
  68. #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
  69. # define SA_RESTART 0x10000000 /* Restart syscall on signal return. */
  70. # define SA_NODEFER 0x40000000 /* Don't automatically block the signal when
  71. its handler is being executed. */
  72. # define SA_RESETHAND 0x80000000 /* Reset to SIG_DFL on entry to handler. */
  73. #endif
  74. #ifdef __USE_MISC
  75. # define SA_INTERRUPT 0x20000000 /* Historical no-op. */
  76. /* Some aliases for the SA_ constants. */
  77. # define SA_NOMASK SA_NODEFER
  78. # define SA_ONESHOT SA_RESETHAND
  79. # define SA_STACK SA_ONSTACK
  80. #endif
  81. /* Values for the HOW argument to `sigprocmask'. */
  82. #define SIG_BLOCK 0 /* Block signals. */
  83. #define SIG_UNBLOCK 1 /* Unblock signals. */
  84. #define SIG_SETMASK 2 /* Set the set of blocked signals. */
  85. #endif