Repository navigation
Close original standard descriptors and keep C++ streams attached - #579
Open
perfloop-agent wants to merge 2 commits into
Open
perfloop-agent wants to merge 2 commits into
perfloop-agent wants to merge 2 commits into
Conversation
perfloop
Bot
force-pushed
the
perfloop-pr-open-msy2k2kavp
branch
from
November 1, 2026 13:40
3cb5fb0 to
2a70743
Compare
Contributor
|
@perfloop-agent The actual fix is a bit more involved. We need to create a new Stream type to hold state. For example, streams must remember the floating point formatting, string padding, etc. |
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
perfloop
Bot
force-pushed
the
perfloop-pr-open-msy2k2kavp
branch
from
November 2, 2026 12:53
2a70743 to
a5c0693
Compare
Contributor
Author
|
The stream wrapper now separates the mutable stream object from its I/O handle, so formatting and error state can live on the object. References and copied or returned iterators keep that same object instead of duplicating handles. Floating-point formatting and padding remain outside this PR. |
This was referenced Nov 5, 2026
This branch has not been deployed
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.
Summary
Closing a standard descriptor in refcount output now releases the OS descriptor with that number, so open can reuse it. C++ standard streams stay attached to the original descriptor and return I/O errors after close instead of panicking or using a duplicate.
CppStreamas a mutable stream object separate from its I/O handle, leaving a home for future formatting and error state.Generated refcount code remains safe Rust. The registry remains thread-local, with its existing
ub: bad fdpolicy for unregistered numbers, including a first close after another thread has closed that descriptor. This is not cross-thread ownership tracking.Floating-point formatting, padding, and sticky error flags remain unimplemented; insertion expressions still discard returned I/O errors. Application exposure and runtime performance remain unmeasured.
Testing
8 recorded checks pass with this change.
The runtime runner passes 71 unit tests, with no failures or ignored tests, and reports no doctests. The scoped lit runner passes 44 cases, with no failures or skips.
tests/unit/fd_close_standard.c compares close/open/read and descriptor-number reuse with native C. The unsafe model's descriptor-close behavior is unchanged.
tests/unit/iostream_closed.cpp compares output after closing stdout and stderr with native C++. tests/unit/stdcopy_ostream.cpp exercises copied and returned output iterators and reads the file back. tests/unit/stdcopy_istream.cpp checks binary file-to-string reads through temporary and copied input iterators. The runtime's
file_stream_iotest covers binary I/O and release of the owned file while stream references remain.The macOS
unit/max.cpp/refcountgenerated-output check remains owned by target CI.Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart.