From 0b9173efd9d9305b0191fd705dd447653f4962ea Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 27 Jun 2012 13:54:05 -0700 Subject: [PATCH] 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. --- lib/vagrant/util/subprocess.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/util/subprocess.rb b/lib/vagrant/util/subprocess.rb index 0eaa6ba47..31e3c9871 100644 --- a/lib/vagrant/util/subprocess.rb +++ b/lib/vagrant/util/subprocess.rb @@ -102,7 +102,8 @@ module Vagrant while true writers = notify_stdin ? [process.io.stdin] : [] 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 raise TimeoutExceeded, process.pid if timeout && (Time.now.to_i - start_time) > timeout @@ -130,7 +131,7 @@ module Vagrant break if process.exited? # 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? end end