From c1bd7468d5d3e0cd2213fa48778ac4d349fde9e9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 12 Nov 2013 16:19:20 +0000 Subject: [PATCH] builder/virtualbox: ctrl-c works during wait for boot --- CHANGELOG.md | 1 + builder/virtualbox/step_run.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 770adbd46..98755ba44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ BUG FIXES: * builder/amazon/chroot: Copying empty directories works. [GH-588] * builder/amazon/chroot: Chroot commands work with shell provisioners. [GH-581] +* builder/virtualbox: Ctrl-C interrupts during waiting for boot. [GH-618] * builder/vmware: VMX modifications are now case-insensitive. [GH-608] * builder/vmware: VMware Fusion won't ask for VM upgrade. * provisioner/chef-solo: Output is slightly prettier and more informative. diff --git a/builder/virtualbox/step_run.go b/builder/virtualbox/step_run.go index 7fc4e0a7c..1a44c10c2 100644 --- a/builder/virtualbox/step_run.go +++ b/builder/virtualbox/step_run.go @@ -42,7 +42,18 @@ func (s *stepRun) Run(state multistep.StateBag) multistep.StepAction { if int64(config.bootWait) > 0 { ui.Say(fmt.Sprintf("Waiting %s for boot...", config.bootWait)) - time.Sleep(config.bootWait) + wait := time.After(config.bootWait) + WAITLOOP: + for { + select { + case <-wait: + break WAITLOOP + case <-time.After(1 * time.Second): + if _, ok := state.GetOk(multistep.StateCancelled); ok { + return multistep.ActionHalt + } + } + } } return multistep.ActionContinue