Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix up non-native popen init and closing logic wrt write streams.
MRI uses a hidden attribute on IO objects made up of two separate read and write streams (tied_io_for_writing), when it must wrap those streams as if they're a single IO. This is the case for popen, and so we put the write stream into this "tied" field. However, we're only supposed to use the tied field when there's already a read stream. When there's just a write stream, as in The other part of this patch fixes the close logic for non-native popen, so that it will check if either the main stream or the "tied" stream is open before deciding whether to close it. The old logic only considered the primary stream. The first part of this patch (not using "tied" when only writing) hides the failure fixed by the second part of this patch since we see a single-stream normal IO and the original bug does not happen. Note that this probably regressed in 9k because we started using this "tied" field most places, but the non-native popen bits were not updated to test it. If we work on getting more tests green on Windows we should be able to find and eliminate these discrepancies. Fixes #3473.