When I try to read from stdout with normal output all works fine, but when I read from a line the output hangs and exit with Exit code 2, I use StdoutPipe and I read that pipe has a default limit of 65536 byte, so maybe this is the reason for the interruption? the data flies very fast and when reading polyline probably just does not have time to read and pipe overflows? I also tried to copy stdout to the buffer, but it still happens the same program hangs and then kills in general what to do in this case, do you know?
cmd := exec.Command("tshark", "-i", d.device, "-T", "json")
stdoutReader, err := cmd.StdoutPipe()
if err != nil {
log.Println(err)
}
go func() {
var b bytes.Buffer
if _, err := io.Copy(&b, stdoutReader); err != nil {
log.Println(err)
}
}()
scanner := bufio.NewScanner(stdoutReader)
done := make(chan bool)
go func() {
for scanner.Scan() {
fmt.Println(scanner.Bytes())
}
done <- true
}()
if err := cmd.Start(); err != nil {
log.Println(err)
}
<-done
if err = cmd.Wait(); err != nil {
log.Println(err)
}