Avoid deadlock behavior on Windows subprocess IO [GH-765]
This commit is contained in:
parent
748a768941
commit
a90f33dcf2
|
@ -171,6 +171,15 @@ module Vagrant
|
||||||
# Windows doesn't support non-blocking reads on
|
# Windows doesn't support non-blocking reads on
|
||||||
# file descriptors or pipes so we have to get
|
# file descriptors or pipes so we have to get
|
||||||
# a bit more creative.
|
# 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)
|
data << io.readpartial(READ_CHUNK_SIZE)
|
||||||
else
|
else
|
||||||
# Do a simple non-blocking read on the IO object
|
# Do a simple non-blocking read on the IO object
|
||||||
|
|
Loading…
Reference in New Issue