Files
kandev/apps/backend/internal/agentctl/server/process/pty_unix.go
T
Carlos Florêncio cad2d783b3
release / build-web (push) Has been cancelled
release / build-bundles (aarch64-linux-gnu-gcc, arm64, linux, ubuntu-latest, linux-arm64) (push) Has been cancelled
release / build-bundles (amd64, darwin, macos-13, macos-x64) (push) Has been cancelled
release / build-bundles (amd64, linux, ubuntu-latest, linux-x64) (push) Has been cancelled
release / build-bundles (amd64, windows, windows-latest, windows-x64) (push) Has been cancelled
release / build-bundles (arm64, darwin, macos-14, macos-arm64) (push) Has been cancelled
feat: improve windows support (#225)
feat: windows support
2026-02-15 18:16:21 +00:00

37 lines
914 B
Go

//go:build !windows
package process
import (
"os"
"os/exec"
"github.com/creack/pty"
)
// unixPTY wraps a Unix PTY master file descriptor.
type unixPTY struct {
f *os.File
}
func (p *unixPTY) Read(b []byte) (int, error) { return p.f.Read(b) }
func (p *unixPTY) Write(b []byte) (int, error) { return p.f.Write(b) }
func (p *unixPTY) Close() error { return p.f.Close() }
func (p *unixPTY) Resize(cols, rows uint16) error {
return pty.Setsize(p.f, &pty.Winsize{Cols: cols, Rows: rows})
}
// startPTYWithSize starts the command in a Unix PTY with the given dimensions.
// The command is started via pty.StartWithSize which calls cmd.Start() internally.
func startPTYWithSize(cmd *exec.Cmd, cols, rows int) (PtyHandle, error) {
f, err := pty.StartWithSize(cmd, &pty.Winsize{
Cols: uint16(cols),
Rows: uint16(rows),
})
if err != nil {
return nil, err
}
return &unixPTY{f: f}, nil
}