lib/vagrant/batch_action.rb in vagrant-unbundled-2.2.4.0 vs lib/vagrant/batch_action.rb in vagrant-unbundled-2.2.5.0

- old
+ new

@@ -69,10 +69,14 @@ # calling the action but also contains some error handling in it # as well. thread = Thread.new do Thread.current[:error] = nil + # Note that this thread is being used for running + # a batch action + Thread.current[:batch_parallel_action] = par + # Record our pid when we started in order to figure out if # we've forked... start_pid = Process.pid begin @@ -157,9 +161,19 @@ end end if !errors.empty? raise Errors::BatchMultiError, message: errors.join("\n\n") + end + + # Check if any threads set an exit code and exit if found. If + # multiple threads have exit code values set, the first encountered + # will be the value used. + threads.each do |thread| + if thread[:exit_code] + @logger.debug("Found exit code set within batch action thread. Exiting") + Process.exit!(thread[:exit_code]) + end end end end end