Skip to content

Commit

Permalink
Windows subprocess IO works again. [hashicorpGH-721]
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Feb 10, 2012
1 parent 600e8ae commit 0ba3824
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.9.7 (unreleased)

- Fix regression where all subprocess IO simply didn't work with
Windows. [GH-721]

## 0.9.6 (February 7, 2012)

- Fix strange issue with inconsistent childprocess reads on JRuby. [GH-711]
Expand Down
19 changes: 14 additions & 5 deletions lib/vagrant/util/subprocess.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def execute
# Make sure the stdin does not buffer
process.io.stdin.sync = true

if RUBY_PLATFORM != "java"
# On Java, we have to close after. See down the method...
# Otherwise, we close the writers right here, since we're
# not on the writing side.
stdout_writer.close
stderr_writer.close
end

# Create a dictionary to store all the output we see.
io_data = { :stdout => "", :stderr => "" }

Expand Down Expand Up @@ -136,11 +144,12 @@ def execute
yield io_name, extra_data if block_given?
end

# Close the writer pipes. Note that we do this so late (after the process
# has quit) to work around an issue with childprocess and JRuby. It is
# bizarre but it works.
stdout_writer.close
stderr_writer.close
if RUBY_PLATFORM == "java"
# On JRuby, we need to close the writers after the process,
# for some reason. See GH-711.
stdout_writer.close
stderr_writer.close
end

# Return an exit status container
return Result.new(process.exit_code, io_data[:stdout], io_data[:stderr])
Expand Down

0 comments on commit 0ba3824

Please sign in to comment.