-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: CombinedOutput hangs when exec'd task forks a "daemon" #13155
Comments
What's your go version? I can't reproduce it on |
On Thu, Nov 05, 2015 at 10:11:26AM -0800, Burcu Dogan wrote:
go version go1.5.1 linux/amd64 |
See comments, this is another instance of: golang/go#13155 Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
I have the same behavior here https://groups.google.com/forum/#!topic/golang-nuts/cwEk8lfV_e8 |
This issue is still open; I don't see a need to create a new issue unless you think it is a different problem. |
Direct usage of io.Writer may lead to Wait hanging golang/go#13155
This is working as intended. https://golang.org/pkg/os/#Process.Kill
Also see @ianlancetaylor's comment on this - #24220 (comment). |
Consider https://gist.github.com/felixge/452a5a192e217a2a51c0
I get a similar stack trace:
which for me is roughly:
go/src/os/exec/exec.go
Line 340 in c4fa25f
Based on a cursory glance through the code, it seems like what is happening is that the std{in,out,err} reading/writing goroutines are blocking on reading the stdin of the process, which isn't closed when the child exits, because the grandchild shares the same fds (and doesn't close them). Wait() attempts to address this with a call to
closeDescriptors
, but it is after a blocking wait on the goroutines exiting, so it doesn't work either.The behavior I'd expect is that CombinedOutput() reports exactly what the child task printed, and returns when it exits. At least in the example above, I think it can be resolved by closing the stdin fd for the child once the child exits (but before waiting on the goroutines). However, I haven't tried it and I can imagine other cases where it would still hang.
The text was updated successfully, but these errors were encountered: