feat(cli/ssh): simplify log file flags (#7863)

And, fix a race condition.
This commit is contained in:
Ammar Bandukwala
2023-06-12 09:18:33 +04:00
committed by GitHub
parent ec7b117878
commit 5de1084639
5 changed files with 92 additions and 77 deletions
+13
View File
@@ -448,6 +448,19 @@ func (inv *Invocation) Run() (err error) {
panic(err)
}
}()
// We close Stdin to prevent deadlocks, e.g. when the command
// has ended but an io.Copy is still reading from Stdin.
defer func() {
if inv.Stdin == nil {
return
}
rc, ok := inv.Stdin.(io.ReadCloser)
if !ok {
return
}
e := rc.Close()
err = errors.Join(err, e)
}()
err = inv.run(&runState{
allArgs: inv.Args,
})