fix(init): removed unnecessary error message when waiting for child process; race with wait all
fix(exec): fallback to os.Args when no delimiter found fix(pidproxy): fallback to os.Args when no delimiter found fix(splitargs): return full selfArgs fix(experiment/starter): replaced bool no-wait with count test(docker/bookworm-newconfig): added test for background process + pid proxy
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
@@ -10,14 +12,26 @@ func getVersion(binPath string) (string, error) {
|
||||
outBytes []byte
|
||||
err error
|
||||
output string
|
||||
stdout io.ReadCloser
|
||||
n int
|
||||
)
|
||||
cmd := exec.Command(binPath, "version")
|
||||
outBytes, err = cmd.Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if stdout, err = cmd.StdoutPipe(); err != nil {
|
||||
return "", fmt.Errorf("setting up stdout reader: %w", err)
|
||||
}
|
||||
|
||||
output = string(outBytes)
|
||||
if err = cmd.Start(); err != nil {
|
||||
return "", fmt.Errorf("starting process: %w", err)
|
||||
}
|
||||
|
||||
outBytes = make([]byte, 1024)
|
||||
if n, err = stdout.Read(outBytes); err != nil {
|
||||
return "", fmt.Errorf("reading stdout: %w", err)
|
||||
}
|
||||
|
||||
_ = cmd.Wait()
|
||||
|
||||
output = string(outBytes[:n])
|
||||
output = strings.TrimRight(output, versionTrimRightCutSet)
|
||||
return output, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user