2 * Copyright (c) 2009 Mark Heily <mark@heily.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include "sys/event.h"
22 const struct filter evfilt_proc = EVFILT_NOTIMPL;
25 kevent_wait(struct kqueue *kq, const struct timespec *timeout)
29 dbg_puts("waiting for events");
30 kq->kq_rfds = kq->kq_fds;
31 n = pselect(kq->kq_nfds, &kq->kq_rfds, NULL , NULL, timeout, NULL);
34 dbg_puts("signal caught");
37 dbg_perror("pselect(2)");
45 kevent_copyout(struct kqueue *kq, int nready,
46 struct kevent *eventlist, int nevents)
52 for (i = 0; (i < EVFILT_SYSCOUNT && nready > 0 && nevents > 0); i++) {
53 // dbg_printf("eventlist: n = %d nevents = %d", nready, nevents);
54 filt = &kq->kq_filt[i];
55 // dbg_printf("pfd[%d] = %d", i, filt->kf_pfd);
56 if (FD_ISSET(filt->kf_pfd, &kq->kq_rfds)) {
57 dbg_printf("pending events for filter %d (%s)", filt->kf_id, filter_name(filt->kf_id));
58 rv = filt->kf_copyout(filt, eventlist, nevents);
60 dbg_puts("kevent_copyout failed");