>From the Stdout/Stderr field documentation on the os/exec.Cmd type <https://pkg.go.dev/os/exec#Cmd>:
"If Stdout and Stderr are the same writer, and have a type that can be compared with ==, at most one goroutine at a time will call Write." On Tuesday, October 3, 2023 at 9:55:16 PM UTC-4 王富民awaw wrote: exec.CombinedOutput uses the same io.Writer for both stdout and stderr in exec.go - Go (opensource.google) <https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/os/exec/exec.go;l=1003> . This io.Writer is written in exec.go - Go (opensource.google) <https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/os/exec/exec.go;l=717> . These two writes happens concurrently in two goroutines in exec.go - Go (opensource.google) <https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/os/exec/exec.go;l=717> . As far as I know, bytes.Buffer is not safe to concurrent writes. Is this not a race? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/bc7b78b6-cea2-40ac-b6e2-9976e4efe122n%40googlegroups.com.