mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-11 15:39:33 -05:00
e2e-upgrade: guard function return values behind sync.WaitGroup
(#3461)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
132218ac1e
commit
4b7cd84eaf
@ -182,7 +182,8 @@ func runCommandWithSeparateOutputs(cmd *exec.Cmd) (stdout, stderr []byte, err er
|
||||
return
|
||||
}
|
||||
|
||||
continuouslyPrintOutput := func(r io.Reader, prefix string) {
|
||||
continuouslyPrintOutput := func(r io.Reader, prefix string, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
output := scanner.Text()
|
||||
@ -196,12 +197,15 @@ func runCommandWithSeparateOutputs(cmd *exec.Cmd) (stdout, stderr []byte, err er
|
||||
}
|
||||
}
|
||||
|
||||
go continuouslyPrintOutput(stdoutIn, "stdout")
|
||||
go continuouslyPrintOutput(stderrIn, "stderr")
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(2)
|
||||
go continuouslyPrintOutput(stdoutIn, "stdout", wg)
|
||||
go continuouslyPrintOutput(stderrIn, "stderr", wg)
|
||||
|
||||
if err = cmd.Wait(); err != nil {
|
||||
err = fmt.Errorf("wait for command to finish: %w", err)
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
return stdout, stderr, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user