fixed a bug in the kqueue-based implementation