1275970Scy/*
2275970Scy * Copyright 2000-2007 Niels Provos <provos@citi.umich.edu>
3275970Scy * Copyright 2007-2012 Niels Provos and Nick Mathewson
4275970Scy *
5275970Scy * Redistribution and use in source and binary forms, with or without
6275970Scy * modification, are permitted provided that the following conditions
7275970Scy * are met:
8275970Scy * 1. Redistributions of source code must retain the above copyright
9275970Scy *    notice, this list of conditions and the following disclaimer.
10275970Scy * 2. Redistributions in binary form must reproduce the above copyright
11275970Scy *    notice, this list of conditions and the following disclaimer in the
12275970Scy *    documentation and/or other materials provided with the distribution.
13275970Scy * 3. The name of the author may not be used to endorse or promote products
14275970Scy *    derived from this software without specific prior written permission.
15275970Scy *
16275970Scy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17275970Scy * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18275970Scy * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19275970Scy * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20275970Scy * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21275970Scy * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22275970Scy * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23275970Scy * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24275970Scy * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25275970Scy * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26275970Scy */
27275970Scy#ifndef EVSIGNAL_INTERNAL_H_INCLUDED_
28275970Scy#define EVSIGNAL_INTERNAL_H_INCLUDED_
29275970Scy
30275970Scy#ifndef evutil_socket_t
31275970Scy#include "event2/util.h"
32275970Scy#endif
33275970Scy#include <signal.h>
34275970Scy
35275970Scytypedef void (*ev_sighandler_t)(int);
36275970Scy
37275970Scy/* Data structure for the default signal-handling implementation in signal.c
38275970Scy */
39275970Scystruct evsig_info {
40275970Scy	/* Event watching ev_signal_pair[1] */
41275970Scy	struct event ev_signal;
42275970Scy	/* Socketpair used to send notifications from the signal handler */
43275970Scy	evutil_socket_t ev_signal_pair[2];
44275970Scy	/* True iff we've added the ev_signal event yet. */
45275970Scy	int ev_signal_added;
46275970Scy	/* Count of the number of signals we're currently watching. */
47275970Scy	int ev_n_signals_added;
48275970Scy
49275970Scy	/* Array of previous signal handler objects before Libevent started
50275970Scy	 * messing with them.  Used to restore old signal handlers. */
51275970Scy#ifdef EVENT__HAVE_SIGACTION
52275970Scy	struct sigaction **sh_old;
53275970Scy#else
54275970Scy	ev_sighandler_t **sh_old;
55275970Scy#endif
56275970Scy	/* Size of sh_old. */
57275970Scy	int sh_old_max;
58275970Scy};
59275970Scyint evsig_init_(struct event_base *);
60275970Scyvoid evsig_dealloc_(struct event_base *);
61275970Scy
62275970Scyvoid evsig_set_base_(struct event_base *base);
63275970Scyvoid evsig_free_globals_(void);
64275970Scy
65275970Scy#endif /* EVSIGNAL_INTERNAL_H_INCLUDED_ */
66