From 8c341b0c78b79dab69964349831f1e4e2eefdbde Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 30 Jul 2013 10:48:59 -0700 Subject: [PATCH] packer/plugin: flush os.Stderr whenever a plugin ends --- packer/plugin/client.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packer/plugin/client.go b/packer/plugin/client.go index 3a788065d..fbc458518 100644 --- a/packer/plugin/client.go +++ b/packer/plugin/client.go @@ -244,9 +244,18 @@ func (c *Client) Start() (address string, err error) { // Start goroutine to wait for process to exit go func() { + // Make sure we close the write end of our stderr listener so + // that the log goroutine ends properly. defer stderr_w.Close() + + // Wait for the command to end. cmd.Wait() + + // Log and make sure to flush the logs write away log.Printf("%s: plugin process exited\n", cmd.Path) + os.Stderr.Sync() + + // Mark that we exited c.exited = true }()