Re: [go-nuts] Closing write side of os.Pipe caused different behaviors

2024-11-10 Thread huan xiong
Hi Kurtis, Thanks for your detailed explanation. It all makes sense to me (I figured out the race condition issue after I posted the question. As it was the first time I posted to the group, I couldn't reply to my own question until the moderator approved it). For future me and other beginner

Re: [go-nuts] Closing write side of os.Pipe caused different behaviors

2024-11-07 Thread Kurtis Rader
You have at least three problems. The first is a race condition in the second, goroutine, version of your program. Add a `time.Sleep(time.Second)` just before the `wpipe.Close()` and you should see the same behavior as the non-goroutine version. That provides a hint regarding the primary problem.