Skip to content

implement kqueue watch method for MacOS and BSD #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

omegacoleman
Copy link

  1. support lua 5.1 to lua 5.4 by substitution of lua_objlen with lua_rawlen
  2. implemented kqueue watch monitor

As discussed in previous threads, kqueue is really a crippled API comparing to inotify, and has a few problems with this task. Here is how I workaround its limitations.

  1. Each file need to be opened to be watched. Files would be opened with flags to only get events (with O_EVTONLY) if possible, and is closed upon any event
  2. kqueue could not track move properly like inotify. Here I use the upper directory write event to emit a 'Modify' dir delay, and have it interpreted as 'something changed in this dir, but we don't know what exactly', fortunately rsync is powerful enough to handle this.
  3. kqueue got closed on fork. In freebsd this is fixed by using rfork instead, and in macos a func is called after the fork to recreate the queue.

I tested my impl on FreeBSD & MacOS, and it works fine. This also removes the limitation that it depends on super user & internal xnu interface, which is my initial motivation (to use this project with mbp). Personally I take this as a chance to practice using kqueue as well, so please help me if I messed up sth bleh 😺 .

@omegacoleman
Copy link
Author

#193 #138 #32 #27 some of the related feature-requests, plenty of them around actually

@omegacoleman
Copy link
Author

building with -DWITH_KQUEUE is all it takes, I'll try making a homebrew Formula or sth later when I have time. would really appreciate if anyone volunteers to test it out.

@poelzi
Copy link
Member

poelzi commented Feb 19, 2022

Thanks a lot, looks promising. I will do the review when back from sick leave.
I already did some fixes on 5.4, have to look into details. Please do such changes in seperat commits. You can do this with with rebase -i and then split accordingly.
You try to run add a github workflow for freebsd ?
There seems something exists there already and I would like to prevent it breaking :)
https://github.com/marketplace/actions/freebsd-vm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants