pty

package
v1.206.2 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

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

	// 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