Unverified Commit 2dc70a50 authored by Sebastian Stark's avatar Sebastian Stark Committed by GitHub

Merge pull request #1 from jpiles/master

Merge rsync's stdout and stderr instead of reading them sequentially
parents 250412b0 6671fdb7
......@@ -8,7 +8,6 @@ import (
"bufio"
"errors"
"fmt"
"io"
"log"
"os"
"os/exec"
......@@ -63,21 +62,17 @@ func createRsyncCommand(sn *snapshot, base *snapshot) *exec.Cmd {
// error channel the caller can receive a return status from.
func runRsyncCommand(cmd *exec.Cmd) (chan error, error) {
var err error
stdout, err := cmd.StdoutPipe()
if err != nil {
return nil, err
}
stderr, err := cmd.StderrPipe()
cmdOutput, err := cmd.StdoutPipe()
if err != nil {
return nil, err
}
cmd.Stderr = cmd.Stdout
debugf("starting rsync command")
err = cmd.Start()
if err != nil {
return nil, err
}
multi := io.MultiReader(stdout, stderr)
in := bufio.NewScanner(multi)
in := bufio.NewScanner(cmdOutput)
for in.Scan() {
log.Printf("(rsync) %s", in.Text())
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment