Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: third_party/libevent/sample/signal-test.c

Issue 1531573008: move libevent into base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix shim path Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libevent/sample/event-test.c ('k') | third_party/libevent/sample/time-test.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Compile with:
3 * cc -I/usr/local/include -o signal-test \
4 * signal-test.c -L/usr/local/lib -levent
5 */
6
7 #include <sys/types.h>
8
9 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif
12
13 #include <sys/stat.h>
14 #ifndef WIN32
15 #include <sys/queue.h>
16 #include <unistd.h>
17 #include <sys/time.h>
18 #else
19 #include <windows.h>
20 #endif
21 #include <signal.h>
22 #include <fcntl.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include <errno.h>
27
28 #include <event.h>
29
30 int called = 0;
31
32 static void
33 signal_cb(int fd, short event, void *arg)
34 {
35 struct event *signal = arg;
36
37 printf("%s: got signal %d\n", __func__, EVENT_SIGNAL(signal));
38
39 if (called >= 2)
40 event_del(signal);
41
42 called++;
43 }
44
45 int
46 main (int argc, char **argv)
47 {
48 struct event signal_int;
49
50 /* Initalize the event library */
51 struct event_base* base = event_base_new();
52
53 /* Initalize one event */
54 event_set(&signal_int, SIGINT, EV_SIGNAL|EV_PERSIST, signal_cb,
55 &signal_int);
56 event_base_set(base, &signal_int);
57
58 event_add(&signal_int, NULL);
59
60 event_base_dispatch(base);
61 event_base_free(base);
62
63 return (0);
64 }
65
OLDNEW
« no previous file with comments | « third_party/libevent/sample/event-test.c ('k') | third_party/libevent/sample/time-test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698