pty

package
v1.235.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecWithPTY

func ExecWithPTY(ctx context.Context, cmd *exec.Cmd, opts *Options) error

ExecWithPTY executes a command in a pseudo-terminal with optional output masking.

This function provides TTY emulation while allowing masking of sensitive data in output. It integrates with Atmos's existing pkg/io masking infrastructure.

Platform Support:

  • macOS: Fully supported
  • Linux: Fully supported
  • Windows: Not supported (use regular exec.Cmd.Run instead)

Limitations:

  • PTY merges stderr and stdout into single stream
  • EIO errors may occur when reading from closed PTY (this is normal)
  • Terminal size must be synchronized with host terminal

Example:

ctx := context.Background()
cmd := exec.Command("docker", "exec", "-it", containerID, "bash")
opts := &Options{
    Masker:        ioCtx.Masker(),
    EnableMasking: true,
}
err := ExecWithPTY(ctx, cmd, opts)

func IsSupported

func IsSupported() bool

IsSupported returns true if PTY operations are supported on this platform.

Currently supported platforms:

  • darwin (macOS)
  • linux

Not supported:

  • windows (PTY operations require Unix-like system calls)

Types

type Options

type Options struct {
	// Masker is the masking implementation from pkg/io.
	Masker iolib.Masker

	// EnableMasking enables output masking through the PTY proxy.
	EnableMasking bool

	// DisableStdinForward skips forwarding Stdin to the PTY and skips putting
	// the host terminal into raw mode (like docker -t without -i: the child
	// gets a TTY but receives no input from the host).
	DisableStdinForward bool

	// Stdin provides input to the PTY. If nil, defaults to os.Stdin.
	Stdin io.Reader

	// Stdout receives output from the PTY. If nil, defaults to os.Stdout.
	Stdout io.Writer

	// Stderr receives error output from the PTY. Note: PTY merges stderr with stdout.
	// This is preserved for API consistency but data will not flow here in PTY mode.
	Stderr io.Writer
}

Options represents configuration for PTY execution.

Jump to

Keyboard shortcuts

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