diff --git a/pty/pty_other.go b/pty/pty_other.go index 55f66b4d675c6..869d77fe0b9bd 100644 --- a/pty/pty_other.go +++ b/pty/pty_other.go @@ -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 } diff --git a/pty/ptytest/ptytest.go b/pty/ptytest/ptytest.go index 7abec9f181833..4f67568c8fab7 100644 --- a/pty/ptytest/ptytest.go +++ b/pty/ptytest/ptytest.go @@ -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 }) diff --git a/pty/start_other.go b/pty/start_other.go index 40fe97a15a696..4786f1a3650c7 100644 --- a/pty/start_other.go +++ b/pty/start_other.go @@ -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