This source file includes following definitions.
- signal_cb
- main
1
2
3
4
5
6 #ifdef HAVE_SYS_TYPES_H
7 #include <sys/types.h>
8 #endif
9 #include <sys/stat.h>
10 #ifndef WIN32
11 #ifdef HAVE_SYS_QUEUE_H
12 #include <sys/queue.h>
13 #endif
14 #ifdef HAVE_UNISTD_H
15 #include <unistd.h>
16 #endif
17 #ifdef HAVE_SYS_TIME_H
18 #include <sys/time.h>
19 #endif
20 #else
21 #include <windows.h>
22 #endif
23 #include <signal.h>
24 #include <fcntl.h>
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <string.h>
28 #include <errno.h>
29
30 #include <opal/mca/event/event.h>
31 #include "opal/runtime/opal.h"
32
33 int called = 0;
34
35 void
36 signal_cb(int fd, short event, void *arg)
37 {
38 opal_event_t *signal = arg;
39
40 printf("%s: got signal %d\n", __func__, OPAL_EVENT_SIGNAL(signal));
41
42 if (called >= 2)
43 opal_event.del(signal);
44
45 called++;
46 }
47
48 int
49 main (int argc, char **argv)
50 {
51 opal_event_t signal_int, signal_term;
52
53
54 opal_init();
55
56
57 opal_event.set(opal_event_base, &signal_term, SIGUSR1, OPAL_EV_SIGNAL|OPAL_EV_PERSIST, signal_cb,
58 &signal_term);
59 opal_event.set(opal_event_base, &signal_int, SIGUSR2, OPAL_EV_SIGNAL|OPAL_EV_PERSIST, signal_cb,
60 &signal_int);
61
62 opal_event.add(&signal_int, NULL);
63 opal_event.add(&signal_term, NULL);
64
65 opal_event.dispatch(opal_event_base);
66
67 return (0);
68 }
69