Skip to content

Commit bc231b8

Browse files
gnoackcopybara-github
authored andcommitted
e2etesting/setup: simplify startCommand
PiperOrigin-RevId: 612449589
1 parent 3c1a8ce commit bc231b8

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

fleetspeak/src/e2etesting/setup/setup_components.go

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"io"
87
"io/ioutil"
98
"os"
109
"os/exec"
@@ -71,28 +70,11 @@ func (cc *ComponentsInfo) killAll() {
7170
}
7271
}
7372

74-
// Starts a command and redirects its output to main stdout
73+
// startCommand starts cmd and redirects its output to main stdout and stderr.
7574
func startCommand(cmd *exec.Cmd) error {
76-
stdoutIn, err := cmd.StdoutPipe()
77-
if err != nil {
78-
return err
79-
}
80-
stderrIn, err := cmd.StderrPipe()
81-
if err != nil {
82-
return err
83-
}
84-
err = cmd.Start()
85-
if err != nil {
86-
return fmt.Errorf("cmd.Start() failed: %v", err)
87-
}
88-
89-
go func() {
90-
io.Copy(os.Stdout, stdoutIn)
91-
}()
92-
go func() {
93-
io.Copy(os.Stderr, stderrIn)
94-
}()
95-
return nil
75+
cmd.Stdout = os.Stdout
76+
cmd.Stderr = os.Stderr
77+
return cmd.Start()
9678
}
9779

9880
func getNewClientIDs(admin sgrpc.AdminClient, startTime time.Time) ([]string, error) {

0 commit comments

Comments
 (0)