Skip to content

Commit

Permalink
Support broken inotify support by setting ENTR_INOTIFY_WORKAROUND
Browse files Browse the repository at this point in the history
  • Loading branch information
eradman committed Dec 19, 2019
1 parent 651c573 commit e158c36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- Use a single inotify queue on Linux, limited by
/proc/sys/fs/inotify/max_user_watches
- Set the environment variable `ENTR_INOTIFY_WORKAROUND` to enable a
compatibility mode for platforms with deformed inotify support

= Release History

Expand Down
24 changes: 4 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,11 @@ Source Installation - BSD, Mac OS, and Linux

To see available build options run `./configure -h`

Source Installation - Windows Subsystem for Linux
-------------------------------------------------
Docker and Windows Subsystem for Linux
--------------------------------------

wget http://eradman.com/entrproject/patches/entr-3.9-wsl
patch -p1 < entr-3.9-wsl
./configure
make install

The source patch is the current workaround for deformed [inotify
support on WSL](https://github.com/Microsoft/BashOnWindows/issues/2507).

Source Installation - Docker for Mac
------------------------------------

wget http://eradman.com/entrproject/patches/entr-3.9-docker
patch -p1 < entr-3.9-docker
./configure
make install

The source patch is the current workaround for deformed [inotify
support on Docker for Mac](https://github.com/docker/for-mac/issues/896).
To enable a workaround for incomplete inotify support on WSL or Docker for Mac,
set the environment variable `ENTR_INOTIFY_WORKAROUND`.

Man Page Examples
-----------------
Expand Down
10 changes: 8 additions & 2 deletions missing/kqueue_inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ kqueue(void) {

if (inotify_queue == 0)
inotify_queue = inotify_init();
if (getenv("ENTR_INOTIFY_WORKAROUND"))
warnx("broken inotify workaround enabled");
return inotify_queue;
}

Expand Down Expand Up @@ -138,8 +140,10 @@ kevent(int kq, const struct kevent *changelist, int nchanges, struct
file->fd = -1; /* invalidate */
}
else if (kev->flags & EV_ADD) {
wd = inotify_add_watch(kq /* ifd */, file->fn,
IN_ALL);
if (getenv("ENTR_INOTIFY_WORKAROUND"))
wd = inotify_add_watch(kq, file->fn, IN_ALL|IN_MODIFY);
else
wd = inotify_add_watch(kq, file->fn, IN_ALL);
if (wd < 0)
return -1;
close(file->fd);
Expand Down Expand Up @@ -185,6 +189,8 @@ kevent(int kq, const struct kevent *changelist, int nchanges, struct
if (iev->mask & IN_CREATE) fflags |= NOTE_WRITE;
if (iev->mask & IN_MOVE_SELF) fflags |= NOTE_RENAME;
if (iev->mask & IN_ATTRIB) fflags |= NOTE_ATTRIB;
if (getenv("ENTR_INOTIFY_WORKAROUND"))
if (iev->mask & IN_MODIFY) fflags |= NOTE_WRITE;
if (fflags == 0) continue;

/* merge events if we're not acting on a new file descriptor */
Expand Down

0 comments on commit e158c36

Please sign in to comment.