Skip to content

Commit

Permalink
Asynchronously write stderr and stdout output
Browse files Browse the repository at this point in the history
  • Loading branch information
PouuleT committed Jul 20, 2016
1 parent 4899079 commit 5422104
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func execCmd(cmdString string) error {
return err
}
defer stdoutReader.Close()

stderrReader, err := cmd.StderrPipe()
if err != nil {
return err
Expand All @@ -203,8 +204,8 @@ func execCmd(cmdString string) error {
log.Debugf("Command output:\n")

// write the result
io.Copy(os.Stderr, stderrReader)
io.Copy(os.Stdout, stdoutReader)
go io.Copy(os.Stdout, stdoutReader)
go io.Copy(os.Stderr, stderrReader)

if err := cmd.Wait(); err != nil {
return err
Expand Down

0 comments on commit 5422104

Please sign in to comment.