pty

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pty runs a program on a pseudo terminal: openpty (creack/pty) on Linux and macOS, ConPTY on Windows 10 1809 and later.

Index

Constants

View Source
const SignalHangup = "hangup"

SignalHangup tells the program its terminal went away (SIGHUP on Unix, the same as terminate on Windows).

Variables

View Source
var ErrUnknownSignal = errors.New("pty: unknown signal")

ErrUnknownSignal is returned by Signal for names it does not know.

Functions

This section is empty.

Types

type PTY

type PTY interface {
	// Read returns program output; io.EOF (or another error) once the
	// terminal is gone.
	io.Reader
	// Write sends input to the program.
	io.Writer
	// Resize changes the terminal size.
	Resize(cols, rows int) error
	// Wait blocks until the program exits and returns its exit code
	// (128+signal for a signal death on Unix). Safe to call repeatedly.
	Wait() (exitCode int, err error)
	// Pid is the program's process id.
	Pid() int
	// Signal delivers wire.SignalInterrupt (Ctrl-C through the terminal),
	// wire.SignalTerminate, wire.SignalKill or SignalHangup.
	Signal(name string) error
	// Close releases the terminal. Output still buffered may be lost; call
	// it after Wait.
	Close() error
}

PTY is a running program and the master side of its terminal.

func Start

func Start(argv []string, dir string, env []string, cols, rows int) (PTY, error)

Start runs argv in dir with env (nil inherits) on a new terminal of the given size. The program leads a new session with the terminal as its controlling tty. A program that cannot be found yields an error wrapping exec.ErrNotFound.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL