You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code terminates with a deadlock error when run in isolation. If we replace the usage of io.Pipe with cmd.StdinPipe(), the program terminates normally with the expected error from cmd.Wait().
The root cause is that Wait blocks for all io.Copy operations to complete. This is correct, but in the test case here, the deadlock is on io.pipe.rwait. Adding a pw.Close after pw.Write will remove the deadlock. stdout/stderr won't have this problem since they will receive the broken pipe error.
Fixing this isn't straightforward. Ideally, there would be a way to interrupt the read call in stdin()'s copy goroutine. It could be emulated with a select and an interrupt channel, but then that can leak a copy goroutine. I'm unsure of a clean way of fixing this.
The following code terminates with a deadlock error when run in isolation. If we replace the usage of
io.Pipe
withcmd.StdinPipe()
, the program terminates normally with the expected error fromcmd.Wait()
.This is on Darwin 14.1.0 with go 1.4.2.
The text was updated successfully, but these errors were encountered: