Handle case that `writers` is nil on IO.select in subprocess

This can happen when IO.select timeout is reached when we're listening
for writers.
This commit is contained in:
Mitchell Hashimoto 2012-06-27 13:54:05 -07:00
parent 0b3e703498
commit 0b9173efd9
1 changed files with 3 additions and 2 deletions

View File

@ -102,7 +102,8 @@ module Vagrant
while true while true
writers = notify_stdin ? [process.io.stdin] : [] writers = notify_stdin ? [process.io.stdin] : []
results = IO.select([stdout, stderr], writers, nil, timeout || 5) results = IO.select([stdout, stderr], writers, nil, timeout || 5)
readers, writers = results readers = results[0]
writers = results[1]
# Check if we have exceeded our timeout # Check if we have exceeded our timeout
raise TimeoutExceeded, process.pid if timeout && (Time.now.to_i - start_time) > timeout raise TimeoutExceeded, process.pid if timeout && (Time.now.to_i - start_time) > timeout
@ -130,7 +131,7 @@ module Vagrant
break if process.exited? break if process.exited?
# Check the writers to see if they're ready, and notify any listeners # Check the writers to see if they're ready, and notify any listeners
if !writers.empty? if writers && !writers.empty?
yield :stdin, process.io.stdin if block_given? yield :stdin, process.io.stdin if block_given?
end end
end end