2 * This is free and unencumbered software released into the public domain.
4 * Anyone is free to copy, modify, publish, use, compile, sell, or
5 * distribute this software, either in source code form or as a compiled
6 * binary, for any purpose, commercial or non-commercial, and by any
9 * In jurisdictions that recognize copyright laws, the author or authors
10 * of this software dedicate any and all copyright interest in the
11 * software to the public domain. We make this dedication for the benefit
12 * of the public at large and to the detriment of our heirs and
13 * successors. We intend this dedication to be an overt act of
14 * relinquishment in perpetuity of all present and future rights to this
15 * software under copyright law.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
41 struct timeval tv_a = { 0, 250000 };
42 struct timeval tv_b = { 0, 300000 };
43 struct timeval tv_c = { 0, 350000 };
50 pipe_ev(int fd, int ev, void *data)
52 warn("shouldn't have happened!");
57 timeout_cb(int fd, int ev, void *data)
66 timeout_cancel_b(int fd, int ev, void *data)
68 timeout_cb(fd, ev, data);
69 ev_timer_cancel(tout_b);
73 timeout_quit(int fd, int ev, void *data)
75 timeout_cb(fd, ev, data);
84 alarm(2); /* safety net */
86 /* the ev subsystem needs at least a file descriptor */
93 if (ev_add(p[0], POLLIN, pipe_ev, NULL) == -1)
96 if ((tout_c = ev_timer(&tv_c, timeout_quit, &fired_c)) == 0 ||
97 (tout_b = ev_timer(&tv_b, timeout_cb, &fired_b)) == 0 ||
98 (tout_a = ev_timer(&tv_a, timeout_cancel_b, &fired_a)) == 0)
103 if (fired_a && !fired_b && fired_c)
106 errx(1, "events fired not as expected: a:%d b:%d c:%d",
107 fired_a, fired_b, fired_c);