Documentation
¶
Overview ¶
Package pty runs processes in pseudo-terminals, in pure Go: /dev/ptmx on macOS and Linux, ConPTY on Windows.
Index ¶
- Variables
- type Options
- type PTY
- func (p *PTY) ClearScreen() error
- func (p *PTY) Close() error
- func (p *PTY) Exited() <-chan struct{}
- func (p *PTY) Kill() error
- func (p *PTY) Pid() int
- func (p *PTY) Read(b []byte) (int, error)
- func (p *PTY) Resize(cols, rows, width, height int) error
- func (p *PTY) Wait() (int, error)
- func (p *PTY) Write(b []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("pty: closed")
ErrClosed is returned by Write after Close.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Path is the program; Args its arguments, with Args[0] what the
// program sees as its name ("-zsh" starts a login shell).
Path string
Args []string
// Dir is the working directory, Env the environment ("KEY=value").
Dir string
Env []string
// Cols and Rows are the size of the terminal in cells, Width and
// Height in pixels.
Cols, Rows, Width, Height int
}
Options describe a process to start in a pseudo-terminal.
type PTY ¶
type PTY struct {
// contains filtered or unexported fields
}
PTY is a process running in a pseudo-terminal: Read returns its output, Write types into it.
func (*PTY) ClearScreen ¶
ClearScreen does nothing: the terminal has no screen of its own to clear, unlike ConPTY's console.
func (*PTY) Close ¶
Close hangs up the terminal and the process groups of its session: the process's and those of the jobs it started. Groups ignoring SIGHUP get SIGTERM after a grace period, then SIGKILL. It does not wait for exit; Wait includes the session's shutdown.
func (*PTY) Exited ¶
func (p *PTY) Exited() <-chan struct{}
Exited is closed when the process exited.
func (*PTY) Read ¶
Read reads the output of the process; it returns io.EOF once no process has the terminal open any more, or after Close.