Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
os/exec: exec pipes not closed when LookupPath fails #5071
I was working with spawning a lot of processes that didn't exist from a number of goroutines. For these processes I was opening pipes for stdin, stdout and stderr. After some point my process always got errors like "pipe: too many open files". I quickly went through the sources and it seems that when LookupPath fails, and cmd.Start is called, the open ends of the pipes associated to the command are not closed at that time. Initially I found it hard to reproduce the bug because when the GC gets time to run, it will call the finalizers of the open files which end up closing the pipes. However, with enough go routines running at the same time (which I had in my original program) the problem can be reproduced quite easily. I've attached a small pipebug.go file which demonstrates the problem.