gnunet-android

GNUnet for Android
Log | Files | Refs | README

gnunet_signal_lib.h (3139B)


      1 /*
      2      This file is part of GNUnet.
      3      Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 GNUnet e.V.
      4 
      5      GNUnet is free software: you can redistribute it and/or modify it
      6      under the terms of the GNU Affero General Public License as published
      7      by the Free Software Foundation, either version 3 of the License,
      8      or (at your option) any later version.
      9 
     10      GNUnet is distributed in the hope that it will be useful, but
     11      WITHOUT ANY WARRANTY; without even the implied warranty of
     12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13      Affero General Public License for more details.
     14 
     15      You should have received a copy of the GNU Affero General Public License
     16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18      SPDX-License-Identifier: AGPL3.0-or-later
     19  */
     20 
     21 #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
     22 #error "Only <gnunet_util_lib.h> can be included directly."
     23 #endif
     24 
     25 /**
     26  * @addtogroup libgnunetutil
     27  * Multi-function utilities library for GNUnet programs
     28  * @{
     29  *
     30  * @author Christian Grothoff
     31  *
     32  * @file
     33  * Functions related to signals
     34  *
     35  * @defgroup signal  Signal library
     36  * Manage signal handlers.
     37  * @{
     38  */
     39 
     40 #ifndef GNUNET_SIGNAL_LIB_H
     41 #define GNUNET_SIGNAL_LIB_H
     42 
     43 #ifdef __cplusplus
     44 extern "C"
     45 {
     46 #if 0                           /* keep Emacsens' auto-indent happy */
     47 }
     48 #endif
     49 #endif
     50 
     51 /**
     52  * Context created when a signal handler is installed;
     53  * can be used to restore it to the previous state later.
     54  */
     55 struct GNUNET_SIGNAL_Context;
     56 
     57 
     58 /**
     59  * A signal handler.  Since different OSes have different signatures
     60  * for their handlers, the API only gives the most restrictive
     61  * signature -- no arguments, no return value.  Note that this will
     62  * work even if the OS expects a function with arguments.  However,
     63  * the implementation must guarantee that this handler is not called
     64  * for signals other than the one that it has been registered for.
     65  */
     66 typedef void
     67 (*GNUNET_SIGNAL_Handler) (void);
     68 
     69 
     70 /**
     71  * Install a signal handler that will be run if the
     72  * given signal is received.
     73  *
     74  * @param signal the number of the signal
     75  * @param handler the function to call
     76  * @return context that can be used to restore, NULL on error
     77  */
     78 struct GNUNET_SIGNAL_Context *
     79 GNUNET_SIGNAL_handler_install (int signal,
     80                                GNUNET_SIGNAL_Handler handler);
     81 
     82 
     83 /**
     84  * Uninstall a previously installed signal handler.
     85  *
     86  * @param ctx context that was returned when the
     87  *            signal handler was installed
     88  */
     89 void
     90 GNUNET_SIGNAL_handler_uninstall (struct GNUNET_SIGNAL_Context *ctx);
     91 
     92 
     93 /**
     94  * Raise the given signal by calling the installed signal handlers.  This will
     95  * not use the @em raise() system call but only calls the handlers registered
     96  * through GNUNET_SIGNAL_handler_install().
     97  *
     98  * @param sig the signal to raise
     99  */
    100 void
    101 GNUNET_SIGNAL_raise (const int sig);
    102 
    103 
    104 #if 0                           /* keep Emacsens' auto-indent happy */
    105 {
    106 #endif
    107 #ifdef __cplusplus
    108 }
    109 #endif
    110 
    111 /* ifndef GNUNET_SIGNAL_LIB_H */
    112 #endif
    113 
    114 /** @} */  /* end of group */
    115 
    116 /** @} */ /* end of group addition */
    117 
    118 /* end of gnunet_signal_lib.h */