From 757ad016b10b481986ef5ff61c58227caa1844f6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 30 Dec 2013 12:42:21 -0800 Subject: [PATCH] core: ctrl-c no longer raises trap-context exception --- CHANGELOG.md | 1 + lib/vagrant/ui.rb | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f5491f1a..20bc9b346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ IMPROVEMENTS: BUG FIXES: + - core: Ctrl-C no longer raises "trap context" exception. - core: The version for `Vagrant.configure` can now be an int. [GH-2689] - core: `Vagrant.has_plugin?` tries to use plugin's gem name before registered plugin name [GH-2617] diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index 5f2cf6a6d..d7f11dd04 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -180,11 +180,15 @@ module Vagrant channel = type == :error || opts[:channel] == :error ? $stderr : $stdout # Output! We wrap this in a lock so that it safely outputs only - # one line at a time. - @lock.synchronize do - safe_puts(format_message(type, message, opts), - :io => channel, :printer => printer) - end + # one line at a time. We wrap this in a thread because as of Ruby 2.0 + # we can't acquire locks in a trap context (ctrl-c), so we have to + # do this. + Thread.new do + @lock.synchronize do + safe_puts(format_message(type, message, opts), + :io => channel, :printer => printer) + end + end.join end def scope(scope_name)