2 This file is part of GNUnet.
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 GNUnet e.V.
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.
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.
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/>.
20 * @author Christian Grothoff
23 * Functions related to signals
25 * @defgroup signal Signal library
26 * Manage signal handlers.
30 #ifndef GNUNET_SIGNAL_LIB_H
31 #define GNUNET_SIGNAL_LIB_H
36 #if 0 /* keep Emacsens' auto-indent happy */
42 * Context created when a signal handler is installed;
43 * can be used to restore it to the previous state later.
45 struct GNUNET_SIGNAL_Context;
49 * A signal handler. Since different OSes have different signatures
50 * for their handlers, the API only gives the most restrictive
51 * signature -- no arguments, no return value. Note that this will
52 * work even if the OS expects a function with arguments. However,
53 * the implementation must guarantee that this handler is not called
54 * for signals other than the one that it has been registered for.
57 (*GNUNET_SIGNAL_Handler) (void);
61 * Install a signal handler that will be run if the
62 * given signal is received.
64 * @param signal the number of the signal
65 * @param handler the function to call
66 * @return context that can be used to restore, NULL on error
68 struct GNUNET_SIGNAL_Context *
69 GNUNET_SIGNAL_handler_install (int signal,
70 GNUNET_SIGNAL_Handler handler);
74 * Uninstall a previously installed signal hander.
76 * @param ctx context that was returned when the
77 * signal handler was installed
80 GNUNET_SIGNAL_handler_uninstall (struct GNUNET_SIGNAL_Context *ctx);
84 * Raise the given signal by calling the installed signal handlers. This will
85 * not use the @em raise() system call but only calls the handlers registered
86 * through GNUNET_SIGNAL_handler_install().
88 * @param sig the signal to raise
91 GNUNET_SIGNAL_raise (const int sig);
94 #if 0 /* keep Emacsens' auto-indent happy */
101 /* ifndef GNUNET_SIGNAL_LIB_H */
104 /** @} */ /* end of group */
106 /* end of gnunet_signal_lib.h */