Compatibility fixes for open3 on Windows#6649
Merged
headius merged 8 commits intojruby:jruby-9.2from Apr 6, 2021
Merged
Conversation
751bbde to
390d93f
Compare
The API here is similar enough that this is an easier match than trying to refit our ShellLauncher for these other forms. This change allows the sassc gem extension build to succeed without any native support loaded (or without native process support as on Windows).
This was changed sometime between 8 and 11 from UNIXProcess to ProcessImpl. Note that while this exposes the proper class, it still will not work without opening java.base/java.lang to JRuby.
Channel is intended to be an unbuffered IO construct backed directly by a native file descriptor, but it has subclasses that wrap other types of IO streams. In the case of OutputStream, the wrapper seems to have a crucial flaw: it does not flush the underlying stream. Since Channel provides no way to flush, the buffered data will sit there forever. This change modifies our logic to use a "sync" version of the OutputStream channel wrapper, forcing the underlying stream to flush after each write operation.
These fixes bring test_open3 down to only two hanging specs, which hang due to the inablity to pass raw file descriptors through ProcessBuilder into the eventual subprocess. * Properly propagate options through all methods. * popen2 should inherit stderr from parent. * The wait thread should mimic a Process.detach thread with pid method and thread-local value. * The process exit status should be shifted right 8 bits to mimic native packed process results. * Move Open3.popen3 to using this new logic rather than the one-off custom IO.popen3 we implemented years ago. The new logic behaves better. * Avoid kwrest arguments since they behave poorly in Ruby 2.6 and earlier. * Set process streams to sync. This works together with 5a6912c to ensure that the wrapped OutputStream does not buffer data.
Member
Author
|
Note that the new https://mail.openjdk.java.net/pipermail/core-libs-dev/2021-April/076025.html |
Member
Author
|
This now fixes #6648, tested on Windows 10 with msys/mingw64 tooling installed. |
Contributor
|
I tested it also on 9.3 and you need to add thanks @headius |
Member
Author
|
@ahorek Great catch, thanks! |
5322b78 to
21a7573
Compare
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.
This is a series of fixes to improve the behavior of the
open3library when run on platforms where we cannot support native process launching (currently just Windows).The bulk of changes here rewrite the non-native open3 shim to use java.lang.ProcessBuilder. Environment hash and options hash are also better supported.