Skip to content

Commit 5422104

Browse files
committed
Asynchronously write stderr and stdout output
1 parent 4899079 commit 5422104

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ func execCmd(cmdString string) error {
189189
return err
190190
}
191191
defer stdoutReader.Close()
192+
192193
stderrReader, err := cmd.StderrPipe()
193194
if err != nil {
194195
return err
@@ -203,8 +204,8 @@ func execCmd(cmdString string) error {
203204
log.Debugf("Command output:\n")
204205

205206
// write the result
206-
io.Copy(os.Stderr, stderrReader)
207-
io.Copy(os.Stdout, stdoutReader)
207+
go io.Copy(os.Stdout, stdoutReader)
208+
go io.Copy(os.Stderr, stderrReader)
208209

209210
if err := cmd.Wait(); err != nil {
210211
return err

0 commit comments

Comments
 (0)