This blocks until there's an X11 event available:
int x11_fd = ConnectionNumber(display);
fd_set in_fds;
FD_ZERO(&in_fds);
FD_SET(x11_fd, &in_fds);
select(x11_fd + 1, &in_fds, NULL, NULL, NULL);
This just immediately returns:
int x11_fd = ConnectionNumber(display);
int kq = kqueue();
struct kevent ev;
EV_SET(&ev, x11_fd, EVFILT_READ, EV_ADD, 0, 0, 0);
kevent(kq, &ev, 1, NULL, 0, NULL);
Why? Am I using kqueue
incorrectly?
I'm fairly sure I misunderstood the API of kqueue
.
The call shown in the OP only adds the filters to the queue, it doesn't wait on them. In order to do that, a separate array of kevent
s needs to be passed to the eventlist
param.
kevent(kq, NULL, 0, &ev, 1, NULL);