One issue that came up for me using 1.0 on RHEL 5.7 is this: adding a
new event would always return -1, but strerror(3) revealed that the
status was "Success". Because of this I have to compare strings to find
out if an error really occurred
EV_SET(&evSet, file->fd, EVFILT_VNODE, EV_ADD | EV_CLEAR,
NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND, 0, file);
if (kevent(kq, &evSet, 1, NULL, 0, NULL) == -1)
if (strcmp(strerror(errno), "Success") != 0)
err(1, "failed to register VNODE event list");
On the BSDs and Mac OS testing the exit code of kevent(2) is sufficient.
Is there a reason why a successful call returns -1?
--
Eric Radman | http://eradman.com
It's actually failing internally, so the -1 return code is correct. You are
hitting the following unimplemented function:
int
evfilt_vnode_knote_modify(struct filter *filt, struct knote *kn,
const struct kevent *kev)
{
return (-1); /* FIXME - STUB */
}
The reason you are seeing this is because your program tries to add the same
event twice. The first time calls knote_add() which works fine. The second
time calls knote_modify() which is not implemented for EVFILT_VNODE.
This is a bug in libkqueue, and I've put it on the list of things to fix. As a
workaround, you could avoid hitting the bug by refraining from issuing
multiple calls to kevent() with duplicate EV_ADD kevents.
Regards,
- Mark