From 3938138ebc6787073519d357cfdbe386aae1e20f Mon Sep 17 00:00:00 2001 From: mjarkk Date: Wed, 31 Oct 2018 19:25:52 +0100 Subject: [PATCH] Hopefully fixed circleci --- pkg/commands/exec_live_default.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/commands/exec_live_default.go b/pkg/commands/exec_live_default.go index f8755de26..69cb7dec0 100644 --- a/pkg/commands/exec_live_default.go +++ b/pkg/commands/exec_live_default.go @@ -19,6 +19,7 @@ import ( // NOTE: You don't have to include a enter in the return data this function will do that for you func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(string) string) (errorMessage string, codeError error) { cmdOutput := []string{} + isAlreadyClosed := false splitCmd := ToArgv(command) cmd := exec.Command(splitCmd[0], splitCmd[1:]...) @@ -32,7 +33,12 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s return errorMessage, err } - defer func() { _ = tty.Close() }() + defer func() { + if !isAlreadyClosed { + isAlreadyClosed = true + _ = tty.Close() + } + }() go func() { // Regex to cleanup the command output @@ -52,6 +58,10 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s }() if err := cmd.Wait(); err != nil { + if !isAlreadyClosed { + isAlreadyClosed = true + _ = tty.Close() + } return strings.Join(cmdOutput, " "), err }