Skip to content

kqueue: skip ENOENT entries in watchDirectoryFiles#748

Merged
mattn merged 2 commits into
fsnotify:mainfrom
mattn:fix/issue-727-dangling-symlink-in-dir
Apr 27, 2026
Merged

kqueue: skip ENOENT entries in watchDirectoryFiles#748
mattn merged 2 commits into
fsnotify:mainfrom
mattn:fix/issue-727-dangling-symlink-in-dir

Conversation

@mattn

@mattn mattn commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #727. On kqueue, Watcher.Add on a directory containing a dangling symlink failed because watchDirectoryFiles only swallowed EACCES/EPERM from internalWatch. When unix.Open(O_EVTONLY) followed a symlink to a missing target it returned ENOENT, which propagated up and aborted the whole Add. Add os.ErrNotExist to the same skip path so the entry is marked as seen and watching continues for the rest of the directory. Regression from #681. Adds a regression test under testdata/watch-dir/bug-727.

mattn added 2 commits April 26, 2026 21:41
watchDirectoryFiles only suppressed EACCES/EPERM from internalWatch.
A dangling symlink in the watched directory caused unix.Open to follow
the link and fail with ENOENT, aborting Watcher.Add for the whole
directory. Treat os.ErrNotExist the same as a permission error: mark
the entry as seen and continue. Regression from fsnotify#681.
The dragonfly carve-out was copied from create-unresolvable-symlink,
which creates the dangling symlink after the watch starts and dragonfly
does not deliver an event for that path. bug-727 is the inverse: the
dangling symlink already exists when Add() is called, and the post-watch
event is for a separate file (touch /after). dragonfly produces the
expected CREATE event in that case.

@shogo82148 shogo82148 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ヨシッ

@mattn mattn merged commit 7f03e59 into fsnotify:main Apr 27, 2026
34 of 35 checks passed
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.

Watching a directory fails when it encounters a symbolic link to a nonexistent file

2 participants