fix: Fix close in `pty` and `ptytest` (#3392)

This commit is contained in:
Mathias Fredriksson 2022-08-05 21:31:54 +03:00 committed by GitHub
parent f14efd1a2b
commit b10a1b84e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View File

@ -78,7 +78,7 @@ func (p *otherPty) Close() error {
err := p.pty.Close()
err2 := p.tty.Close()
if err != nil {
if err == nil {
err = err2
}

View File

@ -62,7 +62,7 @@ func create(t *testing.T, ptty pty.PTY, name string) *PTY {
_ = out.closeErr(err)
}()
t.Cleanup(func() {
_ = out.Close
_ = out.Close()
_ = ptty.Close()
<-copyDone
})

View File

@ -28,6 +28,7 @@ func startPty(cmd *exec.Cmd) (PTY, Process, error) {
err = cmd.Start()
if err != nil {
_ = ptty.Close()
_ = tty.Close()
if runtime.GOOS == "darwin" && strings.Contains(err.Error(), "bad file descriptor") {
// MacOS has an obscure issue where the PTY occasionally closes
// before it's used. It's unknown why this is, but creating a new