This sounds to me like a sequencing issue, but the way you've describe it sounds correct. Can you share a trimmed-down bit of code?
The key point is, in the goroutine that reads from the pipe, keep reading until eof and *then* close the pipe. If you close the pipe outside this goroutine, then make sure you wait for the goroutine to finish first, e.g. with a sync.WaitGroup, although I'd have thought after cmd.Wait would be safe enough. "When the pipe reaches EOF or errors out, I close the pipe reader". Can you distinguish between these cases - i.e. are you definitely seeing io.EOF every time, or is there sometimes an error, and if so what's the error? I am just thinking that if you see an error and then close the pipe, but the sender has more to send, then they will EPIPE. But I can't think of an actual situation where that might happen, nor where it would be useful to continue reading from a pipe after an error. What's the Go version? I don't suppose GODEBUG=asyncpreemptoff=1 makes any difference? (Ref <https://github.com/kubernetes/kubernetes/issues/92521>) -- 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/1a9e80f0-3da8-4c51-b09a-a2e565a85e62o%40googlegroups.com.