pty

package
v0.11.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Overview

Package pty wraps github.com/creack/pty to provide a simple Session type for running interactive commands inside a pseudo-terminal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is a single PTY-backed command. Construct with New, then Start.

func New

func New() *Session

New returns a session ready to be started.

func (*Session) Close

func (s *Session) Close() error

Close kills the child if still running and releases the PTY.

func (*Session) Read

func (s *Session) Read(buf []byte) (int, error)

Read pulls bytes from the PTY's master side.

func (*Session) Resize

func (s *Session) Resize(rows, cols uint16) error

Resize tells the kernel the new window size for the slave terminal.

func (*Session) Start

func (s *Session) Start(cmd *exec.Cmd) error

Start launches cmd inside a freshly allocated PTY. The returned session owns the PTY file descriptor. The caller is responsible for calling Close() when finished.

func (*Session) WaitExit

func (s *Session) WaitExit() (int, error)

WaitExit blocks until the child has terminated and returns its exit code. Returns an error if Start was never called.

func (*Session) Write

func (s *Session) Write(buf []byte) (int, error)

Write pushes bytes into the PTY's master side (visible to the child as stdin).

Jump to

Keyboard shortcuts

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