Skip to content

Use kevent64 throughout the macOS poll waiter - #134

Merged
ethindp merged 1 commit into
ethindp:masterfrom
trypsynth:fix/macos-poll-timer
Sep 22, 2026
Merged

ethindp merged 1 commit into
ethindp:masterfrom
trypsynth:fix/macos-poll-timer

Conversation

@trypsynth

Copy link
Copy Markdown
Contributor

On macOS the availability poll thread scans once, establishes its baseline, and never scans again, so no change is ever reported:

[prism DEBUG] Backend Enumerator: Baseline established; notifying
... nothing until shutdown ...
[prism INFO] Backend Enumerator: Shutting down

MacWaiter registers its EVFILT_USER event with kevent, then adds the poll timer with kevent64 and waits with kevent. XNU tags a kqueue with the first variant used on it and rejects the others with EINVAL, so the kevent64 call that adds the timer fails. Its result is not checked, the wait has no timeout, and the thread sleeps until wake() fires at shutdown.

What this does

Uses kevent64 for every call on the kqueue. The timer already needed it for NOTE_LEEWAY, so the other three calls move over to match.

Testing

Ran on GitHub's macos-latest (arm64) and macos-15-intel runners with a custom backend whose is_supported is toggled at a 20 ms poll interval. Before, going unavailable was never reported. After, both transitions are reported.

@ethindp

ethindp commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Thank you, I hate MacOS for reasons like this. Will probably merge tomorrow.

@ethindp
ethindp merged commit 16ffac9 into ethindp:master Sep 22, 2026
65 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.

2 participants