diff --git a/packer/communicator.go b/packer/communicator.go index 448e4aacf..df7216d9c 100644 --- a/packer/communicator.go +++ b/packer/communicator.go @@ -115,16 +115,16 @@ func (r *RemoteCmd) StartWithUi(c Communicator, ui Ui) error { } // Create the channels we'll use for data - exitCh := make(chan int, 1) + exitCh := make(chan struct{}) stdoutCh := iochan.DelimReader(stdout_r, '\n') stderrCh := iochan.DelimReader(stderr_r, '\n') // Start the goroutine to watch for the exit go func() { + defer close(exitCh) defer stdout_w.Close() defer stderr_w.Close() r.Wait() - exitCh <- r.ExitStatus }() // Loop and get all our output diff --git a/packer/communicator_test.go b/packer/communicator_test.go index 7c88e2059..a4c3af3d2 100644 --- a/packer/communicator_test.go +++ b/packer/communicator_test.go @@ -33,7 +33,7 @@ func TestRemoteCmd_StartWithUi(t *testing.T) { rc.Wait() expected := strings.TrimSpace(data) - if uiOutput.String() != expected+"\n" { + if strings.TrimSpace(uiOutput.String()) != expected { t.Fatalf("bad output: '%s'", uiOutput.String()) }