Merge pull request #10666 from chrisroberts/f-sigint-trap-err

Wrap output in thread when being called from within trap-context
This commit is contained in:
Chris Roberts 2019-02-12 16:34:49 -08:00 committed by GitHub
commit 81a7939a76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 2 deletions

View File

@ -66,11 +66,29 @@ module Vagrant
ui = environment[:ui] if environment.key?(:ui)
int_callback = lambda do
if environment[:interrupted]
ui.error I18n.t("vagrant.actions.runner.exit_immediately") if ui
if ui
begin
ui.error I18n.t("vagrant.actions.runner.exit_immediately")
rescue ThreadError
# We're being called in a trap-context. Wrap in a thread.
Thread.new {
ui.error I18n.t("vagrant.actions.runner.exit_immediately")
}.join(THREAD_MAX_JOIN_TIMEOUT)
end
end
abort
end
ui.warn I18n.t("vagrant.actions.runner.waiting_cleanup") if ui && !@@reported_interrupt
if ui && !@@reported_interrupt
begin
ui.warn I18n.t("vagrant.actions.runner.waiting_cleanup")
rescue ThreadError
# We're being called in a trap-context. Wrap in a thread.
Thread.new {
ui.warn I18n.t("vagrant.actions.runner.waiting_cleanup")
}.join(THREAD_MAX_JOIN_TIMEOUT)
end
end
environment[:interrupted] = true
@@reported_interrupt = true
end