process

package
v1.223.0-rc.8 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatScriptDisplay added in v1.223.0

func FormatScriptDisplay(interpreter, script string) string

FormatScriptDisplay returns a readable command preview for show.command.

func NewScriptCommand added in v1.223.0

func NewScriptCommand(ctx context.Context, spec *ScriptSpec) *exec.Cmd

NewScriptCommand builds an exec.Cmd for a script invocation.

func ReplaceShellSession added in v1.222.0

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 RunScript added in v1.223.0

func RunScript(ctx context.Context, spec *ScriptSpec, stdout, stderr io.Writer) error

RunScript executes an inline script with attached output streams.

func RunShellSession added in v1.222.0

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 added in v1.222.0

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).

func ScriptInvocation added in v1.223.0

func ScriptInvocation(interpreter, script string) ([]string, io.Reader)

ScriptInvocation returns the argv and optional stdin needed to execute an inline script directly with the selected interpreter.

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 added in v1.222.0

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
	Signaled     bool
	Signal       string
	SignalNumber int
	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 ScriptSpec added in v1.223.0

type ScriptSpec struct {
	Interpreter string
	Script      string
	Name        string
	Dir         string
	Env         []string
	DryRun      bool
}

ScriptSpec describes an inline script executed by a named interpreter.

type ShellSessionSpec added in v1.222.0

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