Skip to content

fix(utils): honour EFD_NONBLOCK when combined with EFD_SEMAPHORE on macOS - #116

Open
ya-luotao wants to merge 1 commit into
superradcompany:krunfrom
ya-luotao:fix-macos-eventfd-flags
Open

fix(utils): honour EFD_NONBLOCK when combined with EFD_SEMAPHORE on macOS#116
ya-luotao wants to merge 1 commit into
superradcompany:krunfrom
ya-luotao:fix-macos-eventfd-flags

Conversation

@ya-luotao

Copy link
Copy Markdown

Bug

EventFd::new in the macOS pipe-based emulation only sets O_NONBLOCK when flag == EFD_NONBLOCK. pollable_channel creates its eventfd with EFD_NONBLOCK | EFD_SEMAPHORE, so the pipe stays blocking.

Consequence: any consumer that drains a PollableChannelReciever until empty blocks on the read of the empty pipe. The virtio-input worker does exactly that (fill_event_virtqueue calls next_event() until it returns None), so on macOS the worker hung on the second next_event() of the first batch and no input event ever reached the guest. Nothing is logged; the device just never delivers.

Fix

Test the EFD_NONBLOCK bit instead of comparing the whole flag value (one line).

Verification

microsandbox on Apple Silicon (HVF) with the input feature, an Arch Linux ARM guest running Hyprland: before the change, evdev events pushed through a pollable_channel never showed up on /dev/input/event*; after it, libinput sees the keyboard and pointer and Super+K opens Omarchy's cheatsheet. Blk/net/vsock (which also use EventFd) keep working in the same build. Write-up: https://github.com/ya-luotao/msb-omarchy/blob/main/docs/assessment.md

🤖 Generated with Claude Code

https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ

…acOS

The pipe-based eventfd emulation only set O_NONBLOCK when the flags were
exactly EFD_NONBLOCK. pollable_channel creates its eventfd with
EFD_NONBLOCK | EFD_SEMAPHORE, so the pipe stayed blocking and the first
consumer to drain the channel (the virtio-input worker's second
next_event call) blocked forever; no input event ever reached the guest
on macOS. Test the bit instead of the whole value.
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.

1 participant