1 /* $NetBSD: evsignal-internal.h,v 1.5 2020/05/25 20:47:33 christos Exp $ */ 2 3 /* 4 * Copyright 2000-2007 Niels Provos <provos@citi.umich.edu> 5 * Copyright 2007-2012 Niels Provos and Nick Mathewson 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef EVSIGNAL_INTERNAL_H_INCLUDED_ 30 #define EVSIGNAL_INTERNAL_H_INCLUDED_ 31 32 #ifndef evutil_socket_t 33 #include "event2/util.h" 34 #endif 35 #include <signal.h> 36 37 typedef void (*ev_sighandler_t)(int); 38 39 /* Data structure for the default signal-handling implementation in signal.c 40 */ 41 struct evsig_info { 42 /* Event watching ev_signal_pair[1] */ 43 struct event ev_signal; 44 /* Socketpair used to send notifications from the signal handler */ 45 evutil_socket_t ev_signal_pair[2]; 46 /* True iff we've added the ev_signal event yet. */ 47 int ev_signal_added; 48 /* Count of the number of signals we're currently watching. */ 49 int ev_n_signals_added; 50 51 /* Array of previous signal handler objects before Libevent started 52 * messing with them. Used to restore old signal handlers. */ 53 #ifdef EVENT__HAVE_SIGACTION 54 struct sigaction **sh_old; 55 #else 56 ev_sighandler_t **sh_old; 57 #endif 58 /* Size of sh_old. */ 59 int sh_old_max; 60 }; 61 int evsig_init_(struct event_base *); 62 void evsig_dealloc_(struct event_base *); 63 64 void evsig_set_base_(struct event_base *base); 65 void evsig_free_globals_(void); 66 67 #endif /* EVSIGNAL_INTERNAL_H_INCLUDED_ */ 68