From d9d2430ae96d27d3b6afc4b262d59b1efc88b0a9 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Thu, 31 Dec 2020 13:21:14 +0100 Subject: [PATCH] fix: wait for command to complete without wait(), the *ProcessState is nil, meaning we can't access the ExitCode(). On Windows, calling wait() introduces a timeout which makes things run slower, which is why we only call wait() in case of an error. That should not be the main use-case. relates to #285 --- src/environment.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/environment.go b/src/environment.go index 70330643f5f4..fae8dd603081 100644 --- a/src/environment.go +++ b/src/environment.go @@ -201,6 +201,9 @@ func (env *environment) runCommand(command string, args ...string) (string, erro stdoutString := getOutputString(stdout) stderrString := getOutputString(stderr) if stderrString != "" { + // only wait in case of error reduces the lead time on successful + // commands on windows due to not calling process.Wait() + _ = cmd.Wait() return "", &commandError{ err: stderrString, exitCode: cmd.ProcessState.ExitCode(),