Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/exec: exec pipes not closed when LookupPath fails #5071

gopherbot opened this issue Mar 18, 2013 · 4 comments


None yet
4 participants
Copy link

commented Mar 18, 2013

by jessevdk:

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.


  1. pipebug.go (614 bytes)

This comment has been minimized.

Copy link

commented Mar 18, 2013

Comment 1:

Labels changed: added priority-soon, go1.1maybe, removed priority-triage.


This comment has been minimized.

Copy link

commented Mar 18, 2013

Comment 2:


Owner changed to @bradfitz.

Status changed to Started.


This comment has been minimized.

Copy link

commented Mar 18, 2013

Comment 3:

This issue was closed by revision 9db0583.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015

@rsc rsc removed the go1.1maybe label Apr 14, 2015

@golang golang locked and limited conversation to collaborators Jun 24, 2016


This comment has been minimized.

Copy link

commented Feb 23, 2017

CL mentions this issue.

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.