Skip to content

Commit

Permalink
Avoid deadlock behavior on Windows subprocess IO [hashicorpGH-765]
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Feb 28, 2012
1 parent 748a768 commit a90f33d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/vagrant/util/subprocess.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ def read_io(io)
# Windows doesn't support non-blocking reads on
# file descriptors or pipes so we have to get
# a bit more creative.

# Check if data is actually ready on this IO device.
# We have to do this since `readpartial` will actually block
# until data is available, which can cause blocking forever
# in some cases.
results = IO.select([io], nil, nil, 1)
break if !results || results[0].empty?

# Read!
data << io.readpartial(READ_CHUNK_SIZE)
else
# Do a simple non-blocking read on the IO object
Expand Down

0 comments on commit a90f33d

Please sign in to comment.