From c72c8dce4095e070e0679565d5de592cfaaeeffd Mon Sep 17 00:00:00 2001 From: Fabian Ruff Date: Tue, 12 Aug 2014 21:00:02 +0200 Subject: [PATCH] Selecting for duration of timeout can cause hang When specifying a timeout, the subprocess used to select for timeout seconds on the stdout, stderr pipes. This creates a race condition and can cause the `Subprocess#execute` to hang for the full timeout interval if the process has already exited and no more output is send to the pipes. This race is happening with a higher probability if the subprocess is generating a lot of output. --- lib/vagrant/util/subprocess.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant/util/subprocess.rb b/lib/vagrant/util/subprocess.rb index 79d939eee..92669d45a 100644 --- a/lib/vagrant/util/subprocess.rb +++ b/lib/vagrant/util/subprocess.rb @@ -128,7 +128,7 @@ module Vagrant @logger.debug("Selecting on IO") while true writers = notify_stdin ? [process.io.stdin] : [] - results = ::IO.select([stdout, stderr], writers, nil, timeout || 0.1) + results = ::IO.select([stdout, stderr], writers, nil, 0.1) results ||= [] readers = results[0] writers = results[1]