Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pty/start_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package pty
import (
"os"
"os/exec"
"runtime"
"syscall"

"github.com/creack/pty"
Expand All @@ -29,6 +30,13 @@ func startPty(cmd *exec.Cmd) (PTY, *os.Process, error) {
_ = ptty.Close()
return nil, nil, xerrors.Errorf("start: %w", err)
}
go func() {
// The GC can garbage collect the TTY FD before the command
// has finished running. See:
// https://github.com/creack/pty/issues/127#issuecomment-932764012
Comment on lines +34 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a craaaazy race

_ = cmd.Wait()
runtime.KeepAlive(ptty)
}()
oPty := &otherPty{
pty: ptty,
tty: tty,
Expand Down