Skip to content

Duplicate console handles and use them#875

Merged
tompng merged 2 commits into
ruby:masterfrom
YO4:dup_console_handle
Dec 28, 2025
Merged

Duplicate console handles and use them#875
tompng merged 2 commits into
ruby:masterfrom
YO4:dup_console_handle

Conversation

@YO4

@YO4 YO4 commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

dup2() closes @hConsoleHandle/@hConsoleInputHandle when overwriting stdin/stdout.
ruby redirection mechanism does this.

Using closed handle should be avoided.
Since reline cannot detect this, pre-duplicate and use them instead.

fixes #827
also covers #545 #676 , replaces #734

YO4 added 2 commits December 9, 2025 21:08
The Ruby redirection mechanism closes @hConsoleHandle/@hConsoleInputHandle.
Since reline cannot detect this, pre-duplicate and use them instead.

@tompng tompng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for investigating this.
It looks much better than the old workaround in #734. The change and the cause of the bug makes sense.
Let's try this 🚀

@tompng tompng merged commit a416186 into ruby:master Dec 28, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants