Skip to content

Update poll/select/pause to return -EINTR when they cannot block#27049

Open
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:fix_select_errno
Open

Update poll/select/pause to return -EINTR when they cannot block#27049
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:fix_select_errno

Conversation

@sbc100
Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 commented Jun 1, 2026

Previously we were just returning zero in this case (i.e. we were pretending that timeout expired).

This change also restores the old behaviour of the pause() syscall prior to #27044 (because pause is implemented using poll).

This required a fix to select() which was not correctly using __syscall_ret to set the errno valu failure.

Update test_sockets_partial to handle EINTR by returning early.

Add a test case to test_pipe_select to verify that select() returns -1 with EINTR on the main thread when no FDs are ready.

Split out from #27044

@sbc100 sbc100 requested a review from kripken June 1, 2026 23:37
@sbc100 sbc100 force-pushed the fix_select_errno branch from 55a022c to c2fad84 Compare June 1, 2026 23:39
@sbc100 sbc100 mentioned this pull request Jun 1, 2026
sbc100 added a commit that referenced this pull request Jun 2, 2026
We don't support this syscall and musl already has a fall back based on
`poll`/`ppoll`.

Note that the return value for `pause()` now changes to zero (from
ENOSYS), because it is now based in `poll` internally and currently our
`__syscall_poll` implementation returns zero when it would otherwise
need to block. I have another change out the potentially change that
(#27049) but we can consider that separately to this change.

See #27036 and #27038
@sbc100
Copy link
Copy Markdown
Collaborator Author

sbc100 commented Jun 2, 2026

Marking as draft since I'm not sure we really need this change.

@sbc100 sbc100 marked this pull request as draft June 2, 2026 00:55
@sbc100 sbc100 changed the title Update __syscall_poll to return -EINTR when it cannot block Update poll/select/pause to return -EINTR when they cannot block Jun 3, 2026
Previously we were just returning zero in this case (i.e. we were
pretending that timeout expired).

This required a fix to select() to use __syscall_ret so that it
correctly sets errno on failure.

Update test_sockets_partial to handle EINTR by returning early.

Add a test case to test_pipe_select to verify that select() returns -1
with EINTR on the main thread when no FDs are ready.
@sbc100 sbc100 force-pushed the fix_select_errno branch from c2fad84 to 10a3a10 Compare June 3, 2026 00:19
@sbc100 sbc100 marked this pull request as ready for review June 3, 2026 00:21
@sbc100
Copy link
Copy Markdown
Collaborator Author

sbc100 commented Jun 3, 2026

@hoodmane do you think this change will effect you? Do you agree its reasonable thing to do? i.e. when we cannot actually block there is not really a good return code here but most caller of these function should be handling EINTR I would hope?

@hoodmane
Copy link
Copy Markdown
Collaborator

hoodmane commented Jun 3, 2026

I'll try building Python against this commit and see what happens with the test suite.

@hoodmane
Copy link
Copy Markdown
Collaborator

hoodmane commented Jun 3, 2026

Okay I ran the Python test suite on this commit and I don't think it breaks anything.

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.

2 participants