1
0

Do not lose stdout

This commit is contained in:
dump_stack() 2023-05-08 21:35:47 +00:00
parent 1a1afce4f2
commit 15d8ab8137
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -15,6 +15,7 @@ import (
"os/exec"
"runtime"
"strings"
"sync"
"syscall"
"time"
@ -421,7 +422,12 @@ func (q System) Command(user, cmd string) (output string, err error) {
return
}
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
scanner := bufio.NewScanner(stdout)
for scanner.Scan() {
m := scanner.Text()
@ -431,7 +437,10 @@ func (q System) Command(user, cmd string) (output string, err error) {
output = strings.TrimSuffix(output, "\n")
}()
wg.Add(1)
go func() {
defer wg.Done()
scanner := bufio.NewScanner(stderr)
for scanner.Scan() {
m := scanner.Text()
@ -443,6 +452,8 @@ func (q System) Command(user, cmd string) (output string, err error) {
}()
err = session.Wait()
wg.Wait()
return
}