A read parked on a FIFO sees its end on macOS: the IO loop waits with select (#928) - #932
Closed
PedroVIOliv wants to merge 2 commits into
Closed
PedroVIOliv wants to merge 2 commits into
PedroVIOliv wants to merge 2 commits into
Conversation
The JS lane's generic park goes through io_park_on, its run loop tests op once, and io_sys keeps the dlopen symbol table; the C lane resets a queue and sets an effect row in one statement each. The IO comments are tightened with their content kept, and io_fail, io_text, io_tup, io_push and io_park_on use object shorthand and fewer temporaries. comp.ts: 64936 -> 64682 ttok.
… select (bendlang#928) macOS's poll never reports a FIFO's close (nor does kqueue's EVFILT_READ), so a computation parked on one never woke at end of file. select reports it. Both lanes' io_wait now wait with select, the sets sized to the highest parked fd so a descriptor past FD_SETSIZE keeps working as it did under poll: _DARWIN_UNLIMITED_SELECT on the C lane, select$DARWIN_EXTSN on the JS lane, and Linux's select takes sets of any size. The JS lane fires the ready waits in one pass. tests/io/fifo_eof: a child closes the FIFO only once the reader has drained it and parks again, so the last wake is the close alone; after data, with none, and with the reader at fd 1500. comp.ts: 64682 -> 65000 ttok.
PedroVIOliv
force-pushed
the
fifo-eof-928
branch
from
September 21, 2026 03:27
ca754fd to
6612c58
Compare
PedroVIOliv
marked this pull request as ready for review
September 21, 2026 03:28
VictorTaelin
pushed a commit
that referenced
this pull request
Sep 21, 2026
… select macOS's poll never reports a FIFO's close (kqueue neither), so a computation parked on a named pipe never woke at end of file. Both lanes' io_wait now wait with select, its sets sized to the highest parked fd (_DARWIN_UNLIMITED_SELECT on the C lane, select$DARWIN_EXTSN in the JS lane on macOS), so descriptors past 1023 keep working. The IO layer's comments and scheduler say the same in fewer tokens. (#928, PR #932)
Contributor
|
Merged into 2.0.25 as one commit under your authorship, thank you. We reproduced #928 on both lanes (kqueue does not see the close either), confirmed the fix, ran the 26 IO-loop tests on both lanes and trees, and checked Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself. |
Phylliida
pushed a commit
to Phylliida/bend
that referenced
this pull request
Sep 27, 2026
… select macOS's poll never reports a FIFO's close (kqueue neither), so a computation parked on a named pipe never woke at end of file. Both lanes' io_wait now wait with select, its sets sized to the highest parked fd (_DARWIN_UNLIMITED_SELECT on the C lane, select$DARWIN_EXTSN in the JS lane on macOS), so descriptors past 1023 keep working. The IO layer's comments and scheduler say the same in fewer tokens. (bendlang#928, PR bendlang#932)
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.
Fixes #928.
What changed
macOS's
pollnever reports a FIFO's close, so a computation parked on one never wakes at end of file. Both lanes'io_waitnow wait withselect, which does report it. The sets are sized to the highest parked fd, so descriptors above 1023 keep working as they did underpoll:_DARWIN_UNLIMITED_SELECTon macOS; Linux'sselecttakes sets of any size.select$DARWIN_EXTSNon macOS (the plain symbol refuses an fd pastFD_SETSIZE),selectelsewhere.Probed on macOS 15.5 against a FIFO whose writer has closed:
pollwithPOLLINorPOLLIN|POLLPRI|POLLRDNORM|POLLRDBANDnever reports it,kqueueEVFILT_READreturns no event, plainselectreports it but fails at fd 1500, andselect$DARWIN_EXTSNreports it at fd 1500.Commits
comp.ts's cap (the JS generic park goes throughio_park_on, its run loop testsoponce, tighter IO comments, fewer temporaries). comp.ts: 64,936 → 64,682. On its own it changes no test result.gates/repo.tspasses 46/46.Test
tests/io/fifo_eof.bend(C and JS twins): a child writes into a FIFO and closes it only once the reader has drained it and parked again (an ack pipe orders the two), so the reader's last wake is the close alone. Three cases: data then close, close with no data, and the reader at fd 1500. Expected5 / 0 / 5.Checked
On macOS 15.5 arm64: the tests that go through the IO loop (147 files: io, sockets, timers, channels, fibers) give the same results on both lanes before and after each commit, plus the new test. Not run on Linux or on the cluster gates.