Skip to content

macos: avoid leaking ports while awaiting accessibility - #13590

Merged
mitchellh merged 1 commit into
mainfrom
cgeventtap
Aug 4, 2026
Merged

mitchellh merged 1 commit into
mainfrom
cgeventtap

Conversation

@mitchellh

Copy link
Copy Markdown
Contributor

#11799

Creating a CGEventTap without Accessibility permission leaks a Mach port inside CoreGraphics on every failed attempt. The global keybind listener retried this once per second while waiting for permission, so Ghostty eventually exhausted the process port limit.

Request Accessibility access once, poll AXIsProcessTrusted while access is denied, and create the event tap only after access is granted. Stop polling before creation so an unrelated tap failure cannot restart the leaking retry loop.

Tested this with various settings and global keys working fine.

#11799

Creating a CGEventTap without Accessibility permission leaks a Mach
port inside CoreGraphics on every failed attempt. The global keybind
listener retried this once per second while waiting for permission, so
Ghostty eventually exhausted the process port limit.

Request Accessibility access once, poll AXIsProcessTrusted while
access is denied, and create the event tap only after access is
granted. Stop polling before creation so an unrelated tap failure
cannot restart the leaking retry loop.
@mitchellh mitchellh added this to the 1.4.0 milestone Aug 4, 2026
@mitchellh
mitchellh requested a review from a team as a code owner August 4, 2026 03:45
@ghostty-bot ghostty-bot Bot added the os/macos label Aug 4, 2026
@mitchellh
mitchellh merged commit 6687d60 into main Aug 4, 2026
191 checks passed
@mitchellh
mitchellh deleted the cgeventtap branch August 4, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant