Skip to content

Map epoll_ctl() errors through php_poll_errno_to_error() - #23805

Merged
bukka merged 1 commit into
php:masterfrom
nicolas-grekas:io-poll-epoll-errno
Sep 21, 2026
Merged

bukka merged 1 commit into
php:masterfrom
nicolas-grekas:io-poll-epoll-errno

Conversation

@nicolas-grekas

Copy link
Copy Markdown
Contributor

The epoll backend reports everything but EEXIST and ENOENT as ERR_SYSTEM, so a caller cannot tell "this handle cannot be polled" from "polling is broken". The kqueue backend already maps errno through php_poll_errno_to_error(), this makes epoll do the same.

EPERM gets its own case: epoll_ctl() returns it for files that do not implement polling, which means Context::add() fails for regular files, php://temp and /dev/null while Backend::Poll accepts them all:

                    Auto (epoll)                      Poll
regular file        FailedHandleAddException          added ok
/dev/null           FailedHandleAddException          added ok
php://temp          FailedHandleAddException          added ok
pipe                added ok                          added ok
socketpair          added ok                          added ok

That is expected from epoll, and kqueue does not have the problem since it takes regular files. But an event loop has to deal with it, since STDIN is /dev/null in most CI runs and a plain file whenever it is redirected, and today the only way to detect the case is to try the handle again on a Backend::Poll context. With ERROR_NOSUPPORT it can fall back on the spot.

/cc @bukka

The epoll backend reported everything but EEXIST and ENOENT as ERR_SYSTEM, so
a caller could not tell that epoll refuses the handle from a real failure. The
kqueue backend already maps errno, this makes epoll do the same, with EPERM
reported as ERR_NOSUPPORT: that is what epoll_ctl() returns for files that do
not implement polling, such as regular files and /dev/null.

@bukka bukka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense.

@bukka
bukka merged commit 7e5029b into php:master Sep 21, 2026
17 of 18 checks passed
@bukka

bukka commented Sep 21, 2026

Copy link
Copy Markdown
Member

The CI failures seemed unrelated btw.

@nicolas-grekas
nicolas-grekas deleted the io-poll-epoll-errno branch September 21, 2026 15:17
@nicolas-grekas

Copy link
Copy Markdown
Contributor Author

Cool, thanks for merging my PRs !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants