apr_signal.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. 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. #ifndef APR_SIGNAL_H
  17. #define APR_SIGNAL_H
  18. /**
  19. * @file apr_signal.h
  20. * @brief APR Signal Handling
  21. */
  22. #include "apr.h"
  23. #include "apr_pools.h"
  24. #if APR_HAVE_SIGNAL_H
  25. #include <signal.h>
  26. #endif
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif /* __cplusplus */
  30. /**
  31. * @defgroup apr_signal Signal Handling
  32. * @ingroup APR
  33. * @{
  34. */
  35. #if APR_HAVE_SIGACTION || defined(DOXYGEN)
  36. #if defined(DARWIN) && !defined(__cplusplus) && !defined(_ANSI_SOURCE)
  37. /* work around Darwin header file bugs
  38. * http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2657228.html
  39. */
  40. #undef SIG_DFL
  41. #undef SIG_IGN
  42. #undef SIG_ERR
  43. #define SIG_DFL (void (*)(int))0
  44. #define SIG_IGN (void (*)(int))1
  45. #define SIG_ERR (void (*)(int))-1
  46. #endif
  47. /** Function prototype for signal handlers */
  48. typedef void apr_sigfunc_t(int);
  49. /**
  50. * Set the signal handler function for a given signal
  51. * @param signo The signal (eg... SIGWINCH)
  52. * @param func the function to get called
  53. */
  54. APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func);
  55. #if defined(SIG_IGN) && !defined(SIG_ERR)
  56. #define SIG_ERR ((apr_sigfunc_t *) -1)
  57. #endif
  58. #else /* !APR_HAVE_SIGACTION */
  59. #define apr_signal(a, b) signal(a, b)
  60. #endif
  61. /**
  62. * Get the description for a specific signal number
  63. * @param signum The signal number
  64. * @return The description of the signal
  65. */
  66. APR_DECLARE(const char *) apr_signal_description_get(int signum);
  67. /**
  68. * APR-private function for initializing the signal package
  69. * @internal
  70. * @param pglobal The internal, global pool
  71. */
  72. void apr_signal_init(apr_pool_t *pglobal);
  73. /**
  74. * Block the delivery of a particular signal
  75. * @param signum The signal number
  76. * @return status
  77. */
  78. APR_DECLARE(apr_status_t) apr_signal_block(int signum);
  79. /**
  80. * Enable the delivery of a particular signal
  81. * @param signum The signal number
  82. * @return status
  83. */
  84. APR_DECLARE(apr_status_t) apr_signal_unblock(int signum);
  85. /** @} */
  86. #ifdef __cplusplus
  87. }
  88. #endif /* __cplusplus */
  89. #endif /* APR_SIGNAL_H */