From cf823cadb510a909065a702084a28090ad275062 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 1 Oct 2010 10:08:38 -0700 Subject: [PATCH] Action warden doesn't do recovery process on `SystemExit` exceptions, allowing double ctrl-C to work properly again. --- CHANGELOG.md | 2 ++ lib/vagrant/action/warden.rb | 4 ++++ test/vagrant/action/warden_test.rb | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cdf96503..187204390 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.6.4 (unreleased) + - Action warden doesn't do recovery process on `SystemExit` exceptions, + allowing the double ctrl-C to work properly again. [related to GH-166] - Initial Vagrantfile is now heavily commented with various available options. [GH-171] - Box add checks if a box already exists before the download. [GH-170] diff --git a/lib/vagrant/action/warden.rb b/lib/vagrant/action/warden.rb index d4fe68bde..d8aeaa665 100644 --- a/lib/vagrant/action/warden.rb +++ b/lib/vagrant/action/warden.rb @@ -26,6 +26,10 @@ module Vagrant raise Errors::VagrantInterrupt.new if env.interrupted? @stack.unshift(@actions.shift).first.call(env) raise Errors::VagrantInterrupt.new if env.interrupted? + rescue SystemExit + # This means that an "exit" or "abort" was called. In these cases, + # we just exit immediately. + raise rescue Exception => e env["vagrant.error"] = e diff --git a/test/vagrant/action/warden_test.rb b/test/vagrant/action/warden_test.rb index 72377afa7..41a42231f 100644 --- a/test/vagrant/action/warden_test.rb +++ b/test/vagrant/action/warden_test.rb @@ -70,6 +70,20 @@ class ActionWardenTest < Test::Unit::TestCase assert_raises(RuntimeError) { @instance.call(new_env) } end + should "not begin recovery sequence if a SystemExit is raised" do + class Foo + def initialize(*args); end + def call(env) + # Raises a system exit + abort + end + end + + @instance.actions << Foo.new + @instance.expects(:begin_rescue).never + assert_raises(SystemExit) { @instance.call(new_env) } + end + should "raise interrupt if the environment is interupted" do env = new_env env.expects(:interrupted?).returns(true)