mirror of https://github.com/coder/coder.git
fix: Fix close in `pty` and `ptytest` (#3392)
This commit is contained in:
parent
f14efd1a2b
commit
b10a1b84e5
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
})
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue