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

This commit is contained in:
Mitchell Hashimoto 2012-02-28 09:44:28 -08:00
parent 748a768941
commit a90f33dcf2
1 changed files with 9 additions and 0 deletions

View File

@ -171,6 +171,15 @@ module Vagrant
# 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