Skip to content

fix(kqueue): skip unopenable entries during recursive watch - #1039

Open
tlq5l wants to merge 1 commit into
notify-rs:mainfrom
tlq5l:fix/kqueue-skip-unopenable
Open

tlq5l wants to merge 1 commit into
notify-rs:mainfrom
tlq5l:fix/kqueue-skip-unopenable

Conversation

@tlq5l

@tlq5l tlq5l commented Oct 21, 2026

Copy link
Copy Markdown

Description

KqueueWatcher opens every entry of a recursive walk. Since #1017 only NotFound on a child entry is skipped, so any other open error aborts the whole watch. On macOS that happens for setuid binaries such as /usr/bin/sudo (PermissionDenied) and for sockets (EOPNOTSUPP), so watching / or any tree containing them fails.

add_watch_entries now skips child entries (never the root) that fail with NotFound, PermissionDenied or Unsupported, both for walkdir errors and for add_single_watch errors. Other errors, such as a symlink loop or too many open files, still abort.

The existing failed_walk_registers_added_watches test used an unreadable directory as its failing case; it now uses a symlink cycle, since an unreadable directory is skipped. A new test covers an unreadable file, an unreadable directory and a dangling symlink in one tree.

Watching all of / still stops on a symlink loop below /Library/Developer and on the open-file limit; I left both alone as they are separate behaviours.

Ran live: watch("/usr/bin", Recursive) on macOS -> Err(... PermissionDenied ... "/usr/bin/sudo") before, Ok(()) after.

Related Issues

Fixes #703

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.

kqueue watcher cannot recursively watch root directory

1 participant