Apache Portable Runtime
apr_signal.h
Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APR_SIGNAL_H
00018 #define APR_SIGNAL_H
00019 
00020 /**
00021  * @file apr_signal.h
00022  * @brief APR Signal Handling
00023  */
00024 
00025 #include "apr.h"
00026 #include "apr_pools.h"
00027 
00028 #if APR_HAVE_SIGNAL_H
00029 #include <signal.h>
00030 #endif
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif /* __cplusplus */
00035 
00036 /**
00037  * @defgroup apr_signal Signal Handling
00038  * @ingroup APR
00039  * @{
00040  */
00041 
00042 #if APR_HAVE_SIGACTION || defined(DOXYGEN)
00043 
00044 #if defined(DARWIN) && !defined(__cplusplus) && !defined(_ANSI_SOURCE)
00045 /* work around Darwin header file bugs
00046  *   http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2657228.html
00047  */
00048 #undef SIG_DFL
00049 #undef SIG_IGN
00050 #undef SIG_ERR
00051 #define SIG_DFL (void (*)(int))0
00052 #define SIG_IGN (void (*)(int))1
00053 #define SIG_ERR (void (*)(int))-1
00054 #endif
00055 
00056 /** Function prototype for signal handlers */
00057 typedef void apr_sigfunc_t(int);
00058 
00059 /**
00060  * Set the signal handler function for a given signal
00061  * @param signo The signal (eg... SIGWINCH)
00062  * @param func the function to get called
00063  */
00064 APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func);
00065 
00066 #if defined(SIG_IGN) && !defined(SIG_ERR)
00067 #define SIG_ERR ((apr_sigfunc_t *) -1)
00068 #endif
00069 
00070 #else /* !APR_HAVE_SIGACTION */
00071 #define apr_signal(a, b) signal(a, b)
00072 #endif
00073 
00074 
00075 /**
00076  * Get the description for a specific signal number
00077  * @param signum The signal number
00078  * @return The description of the signal
00079  */
00080 APR_DECLARE(const char *) apr_signal_description_get(int signum);
00081 
00082 /**
00083  * APR-private function for initializing the signal package
00084  * @internal
00085  * @param pglobal The internal, global pool
00086  */
00087 void apr_signal_init(apr_pool_t *pglobal);
00088 
00089 /**
00090  * Block the delivery of a particular signal
00091  * @param signum The signal number
00092  * @return status
00093  */
00094 APR_DECLARE(apr_status_t) apr_signal_block(int signum);
00095 
00096 /**
00097  * Enable the delivery of a particular signal
00098  * @param signum The signal number
00099  * @return status
00100  */
00101 APR_DECLARE(apr_status_t) apr_signal_unblock(int signum);
00102 
00103 /** @} */
00104 
00105 #ifdef __cplusplus
00106 }
00107 #endif /* __cplusplus */
00108 
00109 #endif /* APR_SIGNAL_H */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines