Permalink
Browse files

Avoid deadlock behavior on Windows subprocess IO [GH-765]

  • Loading branch information...
1 parent 748a768 commit a90f33dcf280752480b6633746788b927a5f4462 @mitchellh mitchellh committed Feb 28, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/vagrant/util/subprocess.rb
@@ -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

0 comments on commit a90f33d

Please sign in to comment.