1 /* $NetBSD: signal-test.c,v 1.1.1.1 2013/04/11 16:43:31 christos Exp $ */
4 * cc -I/usr/local/include -o signal-test \
5 * signal-test.c -L/usr/local/lib -levent
10 #include <event2/event-config.h>
14 #include <sys/queue.h>
30 #ifdef _EVENT___func__
31 #define __func__ _EVENT___func__
37 signal_cb(evutil_socket_t fd
, short event
, void *arg
)
39 struct event
*signal
= arg
;
41 printf("%s: got signal %d\n", __func__
, EVENT_SIGNAL(signal
));
50 main(int argc
, char **argv
)
52 struct event signal_int
;
53 struct event_base
* base
;
55 WORD wVersionRequested
;
58 wVersionRequested
= MAKEWORD(2, 2);
60 (void) WSAStartup(wVersionRequested
, &wsaData
);
63 /* Initalize the event library */
64 base
= event_base_new();
66 /* Initalize one event */
67 event_assign(&signal_int
, base
, SIGINT
, EV_SIGNAL
|EV_PERSIST
, signal_cb
,
70 event_add(&signal_int
, NULL
);
72 event_base_dispatch(base
);
73 event_base_free(base
);