From 1c65536514f011db131b7624896f0e8fb25e604a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 21 Feb 2014 17:43:45 -0800 Subject: [PATCH] packer: closed pipe is caught [GH-875] --- CHANGELOG.md | 2 ++ packer/ui.go | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6cb25605..b972438d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ BUG FIXES: * core: Fix crash case if blank parameters are given to Packer. [GH-832] * core: Fix crash if big file uploads are done. [GH-897] +* core: Fix crash if machine-readable output is going to a closed + pipe. [GH-875] * builder/docker: user variables work properly. [GH-777] * builder/qemu: reboots are now possible in provisioners. [GH-864] * builder/virtualbox,vmware: iso\_checksum is not required if the diff --git a/packer/ui.go b/packer/ui.go index 0826c5abc..e3f25be89 100644 --- a/packer/ui.go +++ b/packer/ui.go @@ -11,6 +11,7 @@ import ( "runtime" "strings" "sync" + "syscall" "time" "unicode" ) @@ -282,6 +283,11 @@ func (u *MachineReadableUi) Machine(category string, args ...string) { _, err := fmt.Fprintf(u.Writer, "%d,%s,%s,%s\n", now.Unix(), target, category, argsString) if err != nil { - panic(err) + if err == syscall.EPIPE { + // Ignore epipe errors because that just means that the file + // is probably closed or going to /dev/null or something. + } else { + panic(err) + } } }