Documentation ¶
Index ¶
- Variables
- func ApplyTerminalModes(fd int, width int, height int, modes ssh.TerminalModes) error
- type Cmd
- type ConPty
- func (p *ConPty) Close() error
- func (p *ConPty) Command(name string, args ...string) *Cmd
- func (p *ConPty) CommandContext(ctx context.Context, name string, args ...string) *Cmd
- func (p *ConPty) Fd() uintptr
- func (*ConPty) Name() string
- func (p *ConPty) Read(b []byte) (n int, err error)
- func (p *ConPty) Resize(width int, height int) error
- func (p *ConPty) Write(b []byte) (n int, err error)
- type Pty
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidCommand is returned when the command is invalid. ErrInvalidCommand = errors.New("pty: invalid command") // ErrUnsupported is returned when the platform is unsupported. ErrUnsupported = errors.New("pty: unsupported platform") )
Functions ¶
func ApplyTerminalModes ¶
ApplyTerminalModes applies the given ssh terminal modes to the given file descriptor.
Types ¶
type Cmd ¶
type Cmd struct { // Path is the path of the command to run. Path string // Args holds command line arguments, including the command as Args[0]. Args []string // Env specifies the environment of the process. // If Env is nil, the new process uses the current process's environment. Env []string // Dir specifies the working directory of the command. // If Dir is the empty string, the current directory is used. Dir string // SysProcAttr holds optional, operating system-specific attributes. SysProcAttr *syscall.SysProcAttr // Process is the underlying process, once started. Process *os.Process // ProcessState contains information about an exited process. // If the process was started successfully, Wait or Run will populate this // field when the command completes. ProcessState *os.ProcessState // Cancel is called when the command is canceled. Cancel func() error // contains filtered or unexported fields }
Cmd is a command that can be started attached to a pseudo-terminal. This is similar to the API of exec.Cmd. The main difference is that the command is started attached to a pseudo-terminal. This is required as we cannot use exec.Cmd directly on Windows due to limitation of starting a process attached to a pseudo-terminal. See: https://github.com/golang/go/issues/62708
type ConPty ¶
type ConPty struct {
// contains filtered or unexported fields
}
ConPty is a Windows console pseudo-terminal. It uses Windows pseudo console API to create a console that can be used to start processes attached to it.
See: https://docs.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session
func (*ConPty) CommandContext ¶
CommandContext implements Pty.
type Pty ¶
type Pty interface { io.ReadWriteCloser // Name returns the name of the pseudo-terminal. // On Windows, this will always be "windows-pty". // On Unix, this will return the name of the slave end of the // pseudo-terminal TTY. Name() string // Command returns a command that can be used to start a process // attached to the pseudo-terminal. Command(name string, args ...string) *Cmd // CommandContext returns a command that can be used to start a process // attached to the pseudo-terminal. CommandContext(ctx context.Context, name string, args ...string) *Cmd // Resize resizes the pseudo-terminal. Resize(width int, height int) error // Fd returns the file descriptor of the pseudo-terminal. // On Unix, this will return the file descriptor of the master end. // On Windows, this will return the handle of the console. Fd() uintptr }
Pty is a pseudo-terminal interface.