Skip to content

Commit b10a1b8

Browse files
authored
fix: Fix close in pty and ptytest (#3392)
1 parent f14efd1 commit b10a1b8

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

pty/pty_other.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (p *otherPty) Close() error {
7878

7979
err := p.pty.Close()
8080
err2 := p.tty.Close()
81-
if err != nil {
81+
if err == nil {
8282
err = err2
8383
}
8484

pty/ptytest/ptytest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func create(t *testing.T, ptty pty.PTY, name string) *PTY {
6262
_ = out.closeErr(err)
6363
}()
6464
t.Cleanup(func() {
65-
_ = out.Close
65+
_ = out.Close()
6666
_ = ptty.Close()
6767
<-copyDone
6868
})

pty/start_other.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func startPty(cmd *exec.Cmd) (PTY, Process, error) {
2828
err = cmd.Start()
2929
if err != nil {
3030
_ = ptty.Close()
31+
_ = tty.Close()
3132
if runtime.GOOS == "darwin" && strings.Contains(err.Error(), "bad file descriptor") {
3233
// MacOS has an obscure issue where the PTY occasionally closes
3334
// before it's used. It's unknown why this is, but creating a new

0 commit comments

Comments
 (0)