termexec

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNonZeroExitCode = xerrors.New("non-zero exit code")

Functions

This section is empty.

Types

type Process

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

func StartProcess

func StartProcess(ctx context.Context, args StartProcessConfig) (*Process, error)

func (*Process) Close

func (p *Process) Close(logger *slog.Logger, timeout time.Duration) error

Close closes the process using a SIGINT signal or forcefully killing it if the process does not exit after the timeout. It then closes the pseudo terminal.

func (*Process) ReadScreen

func (p *Process) ReadScreen() string

ReadScreen returns the contents of the terminal window. It waits for the terminal to be stable for 16ms before returning, or 48 ms since it's called, whichever is sooner.

This logic acts as a kind of vsync. Agents regularly redraw parts of the screen. If we naively snapshotted the screen, we'd often capture it while it's being updated. This would result in a malformed agent message being returned to the user.

func (*Process) Signal

func (p *Process) Signal(sig os.Signal) error

func (*Process) Wait

func (p *Process) Wait() error

Wait waits for the process to exit.

func (*Process) Write

func (p *Process) Write(data []byte) (int, error)

Write sends input to the process via the pseudo terminal.

type StartProcessConfig

type StartProcessConfig struct {
	Program        string
	Args           []string
	TerminalWidth  uint16
	TerminalHeight uint16
}

Jump to

Keyboard shortcuts

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