Repository navigation
IO.new / IO.for_fd: wrap a descriptor via the synthetic fd table - #483
Merged
Merged
Conversation
rbgo has no real OS file descriptors, so #fileno hands out synthetic ones and now records the stream in a per-VM fd table. IO.new(fd, mode = nil, **opts) and IO.for_fd look a descriptor up there: an unknown one raises Errno::EBADF, and a live one yields a fresh IO carrying the mode's read/write intent and its encoding (from the "mode:ext[:int]" string or the :mode / :external_encoding / :internal_encoding / :encoding options). The fd argument is coerced with #to_int, and the arity is 1..2. Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec floor rises 16180 -> 16240 (core/io for_fd 0 -> 33, new 7 -> 33). Real-fd round-trips (writing through one IO and reading the bytes back through another on the same fd) remain out of reach of the in-memory model. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
rbgo has no real OS file descriptors, so
#filenohands out synthetic ones andnow records the stream in a per-VM fd table.
IO.new(fd, mode = nil, **opts)andIO.for_fdlook a descriptor up there: an unknown one raisesErrno::EBADF, anda live one yields a fresh
IOcarrying the mode's read/write intent and itsencoding (from the
"mode:ext[:int]"string or the:mode/:external_encoding/:internal_encoding/:encodingoptions). The fdargument is coerced with
#to_int, and the arity is 1..2.Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
ratchet floor rises 16180 → 16240 (
core/iofor_fd 0 → 33, new 7 → 33, +59aggregate, zero regressions in a per-file sweep). Real-fd round-trips (writing
through one IO and reading the bytes back through another on the same fd) remain
out of reach of the in-memory model.
🤖 Generated with Claude Code