mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 01:04:14 +00:00
Merge pull request #1755 from calmh/fix-1754
Wait for stdout/stderr to close (fixes #1754)
This commit is contained in:
commit
7e29a8b927
@ -106,12 +106,24 @@ func monitorMain() {
|
|||||||
stdoutLastLines = make([]string, 0, 50)
|
stdoutLastLines = make([]string, 0, 50)
|
||||||
stdoutMut.Unlock()
|
stdoutMut.Unlock()
|
||||||
|
|
||||||
go copyStderr(stderr, dst)
|
wg := sync.NewWaitGroup()
|
||||||
go copyStdout(stdout, dst)
|
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
copyStderr(stderr, dst)
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
copyStdout(stdout, dst)
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
|
||||||
exit := make(chan error)
|
exit := make(chan error)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
wg.Wait()
|
||||||
exit <- cmd.Wait()
|
exit <- cmd.Wait()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -149,7 +161,7 @@ func monitorMain() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyStderr(stderr io.ReadCloser, dst io.Writer) {
|
func copyStderr(stderr io.Reader, dst io.Writer) {
|
||||||
br := bufio.NewReader(stderr)
|
br := bufio.NewReader(stderr)
|
||||||
|
|
||||||
var panicFd *os.File
|
var panicFd *os.File
|
||||||
@ -192,7 +204,7 @@ func copyStderr(stderr io.ReadCloser, dst io.Writer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyStdout(stdout io.ReadCloser, dst io.Writer) {
|
func copyStdout(stdout io.Reader, dst io.Writer) {
|
||||||
br := bufio.NewReader(stdout)
|
br := bufio.NewReader(stdout)
|
||||||
for {
|
for {
|
||||||
line, err := br.ReadString('\n')
|
line, err := br.ReadString('\n')
|
||||||
|
Loading…
Reference in New Issue
Block a user