From 22e734514855f5a2c8fd363569ca896c2dba8733 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 14 Jun 2013 17:37:38 -0700 Subject: [PATCH] packer: Ui requires input for Ctrl-C --- command/build/command.go | 1 - packer/ui.go | 18 +++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/command/build/command.go b/command/build/command.go index c568f6fb4..f83f856ff 100644 --- a/command/build/command.go +++ b/command/build/command.go @@ -210,7 +210,6 @@ func (c Command) Run(env packer.Environment, args []string) int { } } - // Wait for both the builds to complete and the interrupt handler, // if it is interrupted. log.Printf("Waiting on builds to complete...") diff --git a/packer/ui.go b/packer/ui.go index c996b48d1..b8d5c11a9 100644 --- a/packer/ui.go +++ b/packer/ui.go @@ -124,14 +124,18 @@ func (rw *ReaderWriterUi) Ask(query string) string { result <- line }() - select { - case line := <-result: - return line - case <-sigCh: - log.Println("Interrupt during Ask call. Returning immediately.") - fmt.Fprintln(rw.Writer) - return "" + for { + select { + case line := <-result: + return line + case <-sigCh: + fmt.Fprint( + rw.Writer, + "\nInterrupts are blocked while waiting for input. Press enter.") + } } + + return "" } func (rw *ReaderWriterUi) Say(message string) {