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.
43 struct timeval tv_a = { 0, 250000 };
44 struct timeval tv_b = { 0, 300000 };
45 struct timeval tv_c = { 0, 350000 };
52 pipe_ev(int fd, int ev, void *data)
54 warn("shouldn't have happened!");
59 timeout_cb(int fd, int ev, void *data)
68 timeout_cancel_b(int fd, int ev, void *data)
70 timeout_cb(fd, ev, data);
71 ev_timer_cancel(tout_b);
75 timeout_quit(int fd, int ev, void *data)
77 timeout_cb(fd, ev, data);
86 alarm(2); /* safety net */
88 /* the ev subsystem needs at least a file descriptor */
95 if (ev_add(p[0], POLLIN, pipe_ev, NULL) == -1)
98 if ((tout_c = ev_timer(&tv_c, timeout_quit, &fired_c)) == 0 ||
99 (tout_b = ev_timer(&tv_b, timeout_cb, &fired_b)) == 0 ||
100 (tout_a = ev_timer(&tv_a, timeout_cancel_b, &fired_a)) == 0)
105 if (fired_a && !fired_b && fired_c)
108 errx(1, "events fired not as expected: a:%d b:%d c:%d",
109 fired_a, fired_b, fired_c);