You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
poll and epoll_wait on an inotify fd time out after a file event, where Linux reports POLLIN #528
After a watched directory gets an event, poll and epoll_wait on the inotify fd return 0 at their timeout, while a read on the same fd returns the event. On Linux both report the fd readable.
Evidence
On upstream main a20dfab, the probe below compared with elfuse-probe-diff against Linux 6.18.60:
call
elfuse
Linux
poll(fd, POLLIN, 1000) after open(O_CREAT) in the watched dir
0
1, POLLIN
epoll_wait(ep, 1, 1000)
0
1
read(fd)
> 0
> 0
tests/test-inotify.c does not catch this: its poll case calls PASS() when poll returns 0 ("inotify via kqueue may not fire within this short timeout").
Cause
Checked by reading. In src/syscall/inotify.c the guest fd's host fd is the read end of the instance's self-pipe (fd_alloc(FD_INOTIFY, pipefd[0], ...) in sys_inotify_init1), and the file events arrive on a separate kqueue. Only pipe_signal writes the pipe, and its two callers, collect_events and the blocking wait, both run inside inotify_read. src/syscall/poll.c has no inotify case, so poll, ppoll, select and epoll_wait see the pipe empty until the guest reads.
Make the kqueue event raise the pipe byte without a guest read: for example, a watcher that waits on each instance's kq_fd and calls collect_events (which signals the pipe), or a poll/epoll hook for FD_INOTIFY that runs collect_events before it waits and adds kq_fd to the host wait set. Either way, tests/test-inotify.c should fail when poll returns 0.
Origin
Follow-up from #525. Related: #412 (a dup of an inotify fd has no state; a different cause).
Activity