process

package
v1.222.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceShellSession

func ReplaceShellSession(spec *ExecSpec) error

ReplaceShellSession replaces the Atmos process with the spec's command (execve of the system shell). On success it never returns: the command inherits the terminal, file descriptors, environment, and working directory, and its exit code becomes the process exit code natively. It returns an error only if the replacement could not be performed (or nil for dry-run).

func RunShellSession

func RunShellSession(ctx context.Context, spec *ShellSessionSpec) error

RunShellSession executes a shell command attached to the user's terminal.

When TTY is set and the platform supports it, the command runs under a pseudo-terminal: output masking is preserved, and (with Interactive) the host terminal switches to raw mode so Ctrl-C reaches the child instead of Atmos. Otherwise the command inherits the real stdin/stdout/stderr file descriptors directly; masking is unavailable in that mode.

Non-zero exits are returned as errUtils.ExitCodeError.

func RunShellStep

func RunShellStep(ctx context.Context, spec *ShellSessionSpec, plain func() error) error

RunShellStep routes a shell-family step: steps that request a terminal (tty and/or interactive) run as terminal-attached sessions; plain steps run via the caller-provided fallback (each execution path keeps its own plain-step behavior: masked interpreter, command runner, output modes).

Types

type DefaultRunner

type DefaultRunner struct{}

DefaultRunner executes tasks with os/exec.

func (DefaultRunner) Run

func (r DefaultRunner) Run(ctx context.Context, spec TaskSpec) (result Result)

Run executes spec with context-aware cancellation and exit-code preservation.

type ExecSpec

type ExecSpec struct {
	// Command is the raw shell command string, run via the system shell.
	Command string
	// Name is a logical name used for logging.
	Name string
	// Dir is the working directory to change to before the replacement ("" keeps the current directory).
	Dir string
	// Env is the fully merged environment, used verbatim. ATMOS_SHLVL is NOT
	// incremented: the session replaces Atmos rather than nesting under it.
	Env []string
	// DryRun logs the command without executing it.
	DryRun bool
}

ExecSpec describes an exec step: a command that replaces the Atmos process entirely (shell exec semantics). Exec steps must be the final step — nothing runs after the replacement, and supervisor features (masking, output capture, retry, timeout) do not apply.

type Result

type Result struct {
	Command    string
	Args       []string
	ExitCode   int
	Err        error
	Started    bool
	Canceled   bool
	StartedAt  time.Time
	FinishedAt time.Time
}

Result contains the outcome of a subprocess invocation.

func (Result) Success

func (r Result) Success() bool

Success reports whether the subprocess completed with exit code 0.

type Runner

type Runner interface {
	Run(ctx context.Context, spec TaskSpec) Result
}

Runner executes a task and returns the observed process result.

func NewDefaultRunner

func NewDefaultRunner() Runner

NewDefaultRunner returns a Runner backed by os/exec.

type ShellSessionSpec

type ShellSessionSpec struct {
	// Command is the raw shell command string, run via the system shell.
	Command string
	// Name is a logical name used for logging.
	Name string
	// Dir is the working directory.
	Dir string
	// Env is the fully merged environment. When empty, os.Environ() is used.
	Env []string
	// TTY allocates a pseudo-terminal when the platform supports it.
	TTY bool
	// Interactive forwards host stdin to the session and suspends the Atmos
	// SIGINT-exit handler so Ctrl-C is handled by the child process.
	Interactive bool
	// DryRun logs the command without executing it.
	DryRun bool
	// Masker applies secret masking to PTY output. When nil, it defaults to
	// iolib.GetContext().Masker() with EnableMasking from the `mask` setting,
	// so call sites don't need masking wiring.
	Masker iolib.Masker
	// EnableMasking enables secret masking of session output where supported.
	EnableMasking bool
}

ShellSessionSpec describes a shell step that attaches to the user's terminal (steps declared with `tty: true` and/or `interactive: true`).

type Streams

type Streams struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

Streams contains the standard streams passed to a subprocess.

func OSStreams

func OSStreams() Streams

OSStreams returns streams connected to the current process standard streams.

type TaskSpec

type TaskSpec struct {
	Command string
	Args    []string
	Dir     string
	Env     []string
	Streams Streams
	DryRun  bool
}

TaskSpec describes a subprocess invocation.

Jump to

Keyboard shortcuts

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