2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_signal_lib.h
23 * @brief functions related to signals
24 * @author Christian Grothoff
27 #ifndef GNUNET_SIGNAL_LIB_H
28 #define GNUNET_SIGNAL_LIB_H
33 #if 0 /* keep Emacsens' auto-indent happy */
39 * Context created when a signal handler is installed;
40 * can be used to restore it to the previous state later.
42 struct GNUNET_SIGNAL_Context;
45 * A signal handler. Since different OSes have different signatures
46 * for their handlers, the API only gives the most restrictive
47 * signature -- no arguments, no return value. Note that this will
48 * work even if the OS expects a function with arguments. However,
49 * the implementation must guarantee that this handler is not called
50 * for signals other than the one that it has been registered for.
52 typedef void (*GNUNET_SIGNAL_Handler) (void);
55 * Install a signal handler that will be run if the
56 * given signal is received.
58 * @param signal the number of the signal
59 * @param handler the function to call
60 * @return context that can be used to restore, NULL on error
62 struct GNUNET_SIGNAL_Context *
63 GNUNET_SIGNAL_handler_install (int signal, GNUNET_SIGNAL_Handler handler);
66 * Uninstall a previously installed signal hander.
68 * @param ctx context that was returned when the
69 * signal handler was installed
72 GNUNET_SIGNAL_handler_uninstall (struct GNUNET_SIGNAL_Context *ctx);
76 * Raise the given signal by calling the installed signal handlers. This will
77 * not use the @em raise() system call but only calls the handlers registered
78 * through GNUNET_SIGNAL_handler_install().
80 * @param sig the signal to raise
83 GNUNET_SIGNAL_raise (const int sig);
86 #if 0 /* keep Emacsens' auto-indent happy */
93 /* ifndef GNUNET_SIGNAL_LIB_H */
95 /* end of gnunet_signal_lib.h */