-
Notifications
You must be signed in to change notification settings - Fork 18k
os/exec: possible race handling stdout&stderr pipes #69060
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
Comments
I think we'll need a reproducer to do anything about this report. |
You didn't really say what the child process is doing, and in particular whether it might itself be spawing other processes. |
The subprocess is quite simple: it's a BusyBox shell (ash) script:
I know about |
Thanks.
I may be misreading, but it seems to me that the pipes in the child are 61465 and 61466, whereas the pipe in the parent is If you send the hanging process a |
Ah, good eye.
|
Thanks. That definitely looks like the parent process is waiting for the pipes to be closed by the child. That is, the kind of thing affected by |
Go version
go version go1.22.6 linux/amd64
Output of
go env
in your module/workspace:What did you do?
This captures the essence of what I'm doing when starting a process. Note that there are other goroutines, in particular a goroutine that is accepting HTTP CONNECT requests concurrently.
I have not yet been able to reproduce the problem with a minimal programme.
I've taken a look at the
os/exec
implementation and haven't yet seen a potential bug, but given the core of what I'm doing is so simple, I have to wonder if there is a bug lurking somewhere in the standard library. It may be a subtle interaction with other file descriptors being created concurrently.What did you see happen?
The
Start()
succeeds, but sometimes theWait()
never returns, despite the process (and all its children) exiting.When
Wait()
never returns, I was able to capture the file descriptors in the child process before it exited:As you can see, stdout and stderr each have the write-side of their own pipe, as expected. The child process (and any dependents) definitely exit shortly afterwards; they do not appear in the process table.
Inside the parent process (the one using
os/exec
), these are the file descriptors:Both the read and write side of the stderr pipe are open, and the stdout pipe is nowhere to be found.
What did you expect to see?
The
Wait()
should return as soon as the process exists.Also, the read-side of the stdout and stderr pipes should be open in the parent process, but not the write-side.
The text was updated successfully, but these errors were encountered: