File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -381,6 +381,16 @@ func (inv *Invocation) run(state *runState) error {
381
381
return nil
382
382
}
383
383
384
+ // CloseStdin closes the invocation's Stdin if it is an io.Closer.
385
+ func (inv * Invocation ) CloseStdin () error {
386
+ // If we don't close Stdin, the io.Copy below may
387
+ // block indefinitely on Stdin Read.
388
+ if rc , ok := inv .Stdin .(io.Closer ); ok {
389
+ return rc .Close ()
390
+ }
391
+ return nil
392
+ }
393
+
384
394
type RunCommandError struct {
385
395
Cmd * Cmd
386
396
Err error
Original file line number Diff line number Diff line change @@ -193,9 +193,7 @@ func (r *RootCmd) ssh() *clibase.Cmd {
193
193
rawSSH .Close ()
194
194
// If we don't close Stdin, the io.Copy below may
195
195
// block indefinitely on Stdin Read.
196
- if rc , ok := inv .Stdin .(io.Closer ); ok {
197
- rc .Close ()
198
- }
196
+ _ = inv .CloseStdin ()
199
197
return nil
200
198
}, logger , client , workspace )
201
199
}()
You can’t perform that action at this time.
0 commit comments