Repository navigation
fs/vfs: Report POLLERR in the read and write sets of select(). - #20648
Merged
Merged
Conversation
select() put a descriptor with POLLERR only in exceptfds. A caller that asked only for readfds or writefds did not see the error: select() returned 0, also with no timeout, where 0 means that the timeout expired. POSIX says that a descriptor is ready for reading or writing when the call would not block, also when it would return an error. For example, a fifth thread that polls a pipe with CONFIG_DEV_PIPE_NPOLLWAITERS=4 gets POLLERR, and its select() with no timeout returned 0 at once. Report POLLERR in readfds and writefds, as Linux does. poll() reports POLLHUP and POLLERR also when they were not asked for, so set only the bits of the sets that the caller asked for. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
xiaoxiang781216
approved these changes
Oct 14, 2026
|
This was referenced Oct 14, 2026
GUIDINGLI
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
depends-on: [/pull/20661 apache/nuttx-apps/pull/3845]
Summary
select()put a descriptor withPOLLERRonly inexceptfds. A caller that asked only forreadfdsorwritefds, which is the usual case, did not see the error:select()returned 0, also with no timeout, where 0 means that the timeout expired.POSIX says that a descriptor is ready for reading (or writing) when the call would not block, "whether or not the function would transfer data successfully", so also when it would return an error. Linux reports
POLLERRin the read and write sets.This PR reports
POLLERRinreadfdsandwritefds.poll()reportsPOLLHUPandPOLLERRalso when they were not asked for, so the PR sets only the bits of the sets that the caller asked for: before, a descriptor inwritefdsonly could also appear inreadfdsonPOLLHUP.exceptfdsdoes not change.Impact
select()callers that ask forreadfdsorwritefdsnow see a descriptor with an error as ready, and the followingread()orwrite()returns the error.exceptfdsis as before.Testing
qemu-armv8a:nsh(flat) withCONFIG_PIPES=yand the defaultCONFIG_DEV_PIPE_NPOLLWAITERS=4. A test program starts 6 threads that callselect()with no timeout on the read end of one pipe, then writes 6 bytes. The pipe has 4 poll slots, so threads 5 and 6 getPOLLERR:select()calls with no timeout that returned 0With this PR the two threads see the descriptor in
readfds, and theirread()waits for the data.ostestexits with status 0 on both. Build:qemu-armv8a:knshandlm3s6965-ek:qemu-flat, no warnings.tools/checkpatch.sh -c -u -m -gpasses.