stassats / kqueue

FFI to kqueue(7) for Common Lisp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Only file-system events (EVFILT_VNODE) are supported.

(with-kqueue (kqueue `(("/tmp/test" ,(logior note-write note-attrib))))
  (read-events kqueue))
blocks

$ echo x >> /tmp/test

 =>

(#<EVENT #P"/tmp/test" flags: NOTE-WRITE>)

The flags are only printed using names, the actual values are integers.

An easy way to check for multiple events:
(member (logior note-write note-read)
        events
        :key #'event-flag
        :test #'logtest)

With a timeout:

(with-kqueue (kqueue `(("/tmp/test" ,(logior note-write note-attrib))))
  (loop for events = (read-events kqueue :timeout 1)
        thereis events
        do (write-line "timed out")))
timed out
timed out

$ echo 10 >> /tmp/test

=>

(#<EVENT #P"/tmp/test" flags: NOTE-WRITE>)

See also https://github.com/stassats/inotify

About

FFI to kqueue(7) for Common Lisp


Languages

Language:Common Lisp 100.0%