ptyman

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 10 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 ptyman owns pseudo-terminal sessions: spawn a process attached to a PTY (ConPTY on Windows), stream its bytes, write input, resize, signal, kill. The interface is ours so the backend is swappable (ADR-006); the first backend delegates to github.com/aymanbagabas/go-pty. Nothing in Phase 0 depends on this package — it exists for the T0 spike and Phase 1 (T11).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("ptyman: signal not supported on this platform")

ErrNotSupported is returned for signals the platform cannot honour.

Functions

This section is empty.

Types

type GoPTY

type GoPTY struct{}

GoPTY is the go-pty backed Manager (creack/pty on POSIX, ConPTY on Windows).

func (GoPTY) Spawn

func (GoPTY) Spawn(ctx context.Context, spec Spec) (Session, error)

Spawn starts spec.Command attached to a fresh PTY.

type Manager

type Manager interface {
	Spawn(ctx context.Context, spec Spec) (Session, error)
}

Manager spawns sessions.

func New

func New() Manager

New returns the default manager.

type Session

type Session interface {
	// Output streams the terminal bytes (what xterm.js renders).
	Output() io.Reader
	// Write sends bytes to the process's stdin (typed input).
	Write(p []byte) (int, error)
	// Resize changes the terminal size.
	Resize(cols, rows int) error
	// Signal pauses/resumes/kills the process. Paused sessions on Windows hold input.
	Signal(sig Signal) error
	// Wait blocks until the process exits and returns its exit error (nil = 0).
	Wait() error
	// PID returns the process id (0 before start / after close).
	PID() int
	// Paused reports the pause state (Windows input-hold or POSIX SIGSTOP).
	Paused() bool
	// Close releases the PTY; kills the process if still running.
	Close() error
}

Session is a running PTY-attached process.

type Signal

type Signal string

Signal is a control action on an owned session.

const (
	SignalPause  Signal = "pause"  // SIGSTOP on POSIX; input-hold on Windows (no process-level equivalent)
	SignalResume Signal = "resume" // SIGCONT on POSIX; releases the input-hold on Windows
	SignalKill   Signal = "kill"   // terminate the process tree
)

type Spec

type Spec struct {
	Command string
	Args    []string
	Dir     string
	Env     []string // nil ⇒ inherit
	Cols    int      // 0 ⇒ 120
	Rows    int      // 0 ⇒ 40
}

Spec describes a process to spawn.

Jump to

Keyboard shortcuts

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