Logo ProcessKit API Reference

Command Module

Pipe-friendly functions over `Command`, mirroring the instance **builder** methods. The run verbs (`RunAsync`/`OutputStringAsync`/`ParseAsync`/…) are instance methods only — end a pipeline with method syntax (`(cmd |> Command.arg "x").RunAsync()`), or go through `Runner.*` with an explicit runner.

Functions and values

Function or value Description

Command.arg value command

Full Usage: Command.arg value command

Parameters:
Returns: Command

Append a single argument.

value : string
command : Command
Returns: Command

Command.arg0 value command

Full Usage: Command.arg0 value command

Parameters:
Returns: Command

Override the child's `argv[0]` independently of `Program` (multicall binaries, login-shell conventions). Unix-only: a set value fails a Windows spawn with `ProcessError.Unsupported`, as does combining it with a `Uid`/`Gid`/`Groups`/`KillOnParentDeath` drop, `Pty`, or a cgroup-backend run — none of their re-`exec`ing helpers has a seam for a distinct `argv[0]`. See `Command.Arg0`.

value : string
command : Command
Returns: Command

Command.args values command

Full Usage: Command.args values command

Parameters:
    values : string seq
    command : Command

Returns: Command

Append several arguments, in order.

values : string seq
command : Command
Returns: Command

Command.cancelGrace grace command

Full Usage: Command.cancelGrace grace command

Parameters:
Returns: Command

Tear a CANCELLED run down gracefully: soft signal, up to `grace` to leave, then the hard kill. Independent of `timeoutGrace`; the outcome stays `ProcessError.Cancelled` either way.

grace : TimeSpan
command : Command
Returns: Command

Command.cancelOn cancellationToken command

Full Usage: Command.cancelOn cancellationToken command

Parameters:
Returns: Command

Also cancel the run when `cancellationToken` fires.

cancellationToken : CancellationToken
command : Command
Returns: Command

Command.cancelSignal signal command

Full Usage: Command.cancelSignal signal command

Parameters:
Returns: Command

Choose the soft signal that opens a `cancelGrace` window (default `Signal.Term`). Inert without `cancelGrace`, and independent of `stopSignal`.

signal : Signal
command : Command
Returns: Command

Command.capturePolicy policy command

Full Usage: Command.capturePolicy policy command

Parameters:
Returns: Command

Shape each decoded line as it enters the capture backlog (redaction at capture); handlers, tees, the streaming verbs and raw byte captures still see the unshaped line. See `Command.CapturePolicy`.

policy : ICapturePolicy
command : Command
Returns: Command

Command.create program

Full Usage: Command.create program

Parameters:
    program : string

Returns: Command

Create a command for the given program.

program : string
Returns: Command

Command.createNoWindow command

Full Usage: Command.createNoWindow command

Parameters:
Returns: Command

Windows: run the child with `CREATE_NO_WINDOW` (no effect on Unix).

command : Command
Returns: Command

Command.currentDir directory command

Full Usage: Command.currentDir directory command

Parameters:
    directory : string
    command : Command

Returns: Command

Set the working directory for the run.

directory : string
command : Command
Returns: Command

Command.encoding enc command

Full Usage: Command.encoding enc command

Parameters:
Returns: Command

Encode text stdin and decode both captured streams with `encoding`.

enc : Encoding
command : Command
Returns: Command

Command.env key value command

Full Usage: Command.env key value command

Parameters:
    key : string
    value : string
    command : Command

Returns: Command

Set an environment variable for the child.

key : string
value : string
command : Command
Returns: Command

Command.envClear command

Full Usage: Command.envClear command

Parameters:
Returns: Command

Start the child's environment empty instead of inheriting the parent's.

command : Command
Returns: Command

Command.envRemove key command

Full Usage: Command.envRemove key command

Parameters:
Returns: Command

Remove an inherited environment variable from the child.

key : string
command : Command
Returns: Command

Command.extraFd targetFd command

Full Usage: Command.extraFd targetFd command

Parameters:
Returns: Command

Add a POSIX full-duplex parent/child channel at child fd `targetFd` (3 or greater). Claim the parent stream once with `RunningProcess.TakeExtraFd(targetFd)` after starting the command.

targetFd : int
command : Command
Returns: Command

Command.gid value command

Full Usage: Command.gid value command

Parameters:
Returns: Command

Run the child under this Unix group id (`setgid`). Unix-only, same notes as `uid`. See `Command.Gid`.

value : int
command : Command
Returns: Command

Command.groups gids command

Full Usage: Command.groups gids command

Parameters:
Returns: Command

Set the child's Unix supplementary groups, replacing the inherited set — the third leg of a privilege drop. Meaningful only alongside a `Uid`/`Gid` drop (else `ProcessError.Spawn`); Unix-only (a set value fails a Windows spawn with `ProcessError.Unsupported`). See `Command.Groups`.

gids : int seq
command : Command
Returns: Command

Command.idleTimeout duration command

Full Usage: Command.idleTimeout duration command

Parameters:
Returns: Command

Kill the run when it produces no output (stdout or stderr) for `duration` — reset by each chunk of output — independent of the total `Command.Timeout`.

duration : TimeSpan
command : Command
Returns: Command

Command.inheritStdin command

Full Usage: Command.inheritStdin command

Parameters:
Returns: Command

Hand the child the parent process's own standard input directly (inherited, no pipe/feeder), for interactive/console programs. See `Command.InheritStdin`.

command : Command
Returns: Command

Command.ioPriority level command

Full Usage: Command.ioPriority level command

Parameters:
Returns: Command

Set the child's **Linux I/O-scheduling** priority (`ioprio_set(2)`) — the block-device axis, not the CPU one `priority` sets. Build the value with `IoPriority.Idle`/`IoPriority.BestEffort`/ `IoPriority.RealTime`. In force from the child's first disk request and inherited by its descendants. Linux-only: a set value fails a Windows/macOS/BSD spawn — and a detached launch — with `ProcessError.Unsupported`. See `Command.IoPriority`.

level : IoPriority
command : Command
Returns: Command

Command.keepStdinOpen command

Full Usage: Command.keepStdinOpen command

Parameters:
Returns: Command

Keep the child's stdin pipe open after the source is exhausted.

command : Command
Returns: Command

Command.killOnParentDeath command

Full Usage: Command.killOnParentDeath command

Parameters:
Returns: Command

Opt in to reaping this child when the parent process dies suddenly (SIGKILL/crash/`TerminateProcess`). Windows reaps the whole Job tree with no extra action; Linux the direct child only via `PR_SET_PDEATHSIG` (`setpriv --pdeathsig`); macOS/BSD fail the spawn with `ProcessError.Unsupported`. Query the platform-fixed scope with `Command.KillOnParentDeathScope`. See `Command.KillOnParentDeath`.

command : Command
Returns: Command

Command.killOnParentDeathScope command

Full Usage: Command.killOnParentDeathScope command

Parameters:
Returns: KillOnParentDeathScope

The platform-fixed scope of `KillOnParentDeath` cleanup — `WholeTree` (Windows), `DirectChildOnly` (Linux), or `Nothing` (macOS/BSD) — independent of whether the verb was set. See `Command.KillOnParentDeathScope`.

command : Command
Returns: KillOnParentDeathScope

Command.lineTerminator terminator command

Full Usage: Command.lineTerminator terminator command

Parameters:
Returns: Command

Frame both captured/streamed streams' lines with `terminator` (default `LineTerminator.Lf`).

terminator : LineTerminator
command : Command
Returns: Command

Command.logger logger command

Full Usage: Command.logger logger command

Parameters:
Returns: Command

Emit structured lifecycle events to `logger` (argv/env never logged).

logger : ILogger
command : Command
Returns: Command

Command.mergeStderr command

Full Usage: Command.mergeStderr command

Parameters:
Returns: Command

Merge the child's stderr into its stdout at the OS level (like a shell `2>&1`); the two streams then interleave byte-for-byte on the single stdout stream, and there is no separate stderr stream. See `Command.MergeStderr`.

command : Command
Returns: Command

Command.okCodes codes command

Full Usage: Command.okCodes codes command

Parameters:
    codes : int seq
    command : Command

Returns: Command

Replace the success exit-code set with these codes (default `{0}`; include `0` to keep it). An empty set is rejected at the builder boundary with `ArgumentException`. See `Command.OkCodes`.

codes : int seq
command : Command
Returns: Command

Command.onStderrLine handler command

Full Usage: Command.onStderrLine handler command

Parameters:
    handler : string -> unit
    command : Command

Returns: Command

Invoke `handler` for each captured stderr line.

handler : string -> unit
command : Command
Returns: Command

Command.onStdoutLine handler command

Full Usage: Command.onStdoutLine handler command

Parameters:
    handler : string -> unit
    command : Command

Returns: Command

Invoke `handler` for each captured stdout line.

handler : string -> unit
command : Command
Returns: Command

Command.outputBuffer policy command

Full Usage: Command.outputBuffer policy command

Parameters:
Returns: Command

Bound the in-memory backlog of captured lines.

policy : OutputBufferPolicy
command : Command
Returns: Command

Command.preferLocal directory command

Full Usage: Command.preferLocal directory command

Parameters:
    directory : string
    command : Command

Returns: Command

Add `directory` to the prefer-local search list, consulted before `PATH` when resolving the command's bare-name program (searched in the order added; a match is launched by its resolved absolute path). See `Command.PreferLocal`.

directory : string
command : Command
Returns: Command

Command.priority level command

Full Usage: Command.priority level command

Parameters:
Returns: Command

Launch the child (and its spawned tree) at a lower/higher CPU-scheduling priority (Windows priority class / Unix nice). Supported on both platforms; the default leaves the OS default.

level : Priority
command : Command
Returns: Command

Command.pty command

Full Usage: Command.pty command

Parameters:
Returns: Command

Run the child under a pseudo-terminal (PTY) with the default 80×24 geometry (echo on) — a single merged stdout+stderr terminal stream, for tools that demand a tty. Windows: ConPTY (Win10 1809+); POSIX: a real controlling pty via `openpty` + the `setsid --ctty` helper (util-linux); a host missing that ctty helper or the pty devfs (macOS/BSD) fails with `ProcessError.Unsupported`. See `Command.Pty`.

command : Command
Returns: Command

Command.ptyConfig pty command

Full Usage: Command.ptyConfig pty command

Parameters:
Returns: Command

Run the child under a pseudo-terminal (PTY) with a full `PtyConfig` (geometry, echo). See `Command.Pty(PtyConfig)`.

pty : PtyConfig
command : Command
Returns: Command

Command.ptySize cols rows command

Full Usage: Command.ptySize cols rows command

Parameters:
    cols : int
    rows : int
    command : Command

Returns: Command

Run the child under a pseudo-terminal (PTY) with the given initial geometry (echo on). See `Command.Pty(cols, rows)`.

cols : int
rows : int
command : Command
Returns: Command

Command.retry maxAttempts delay shouldRetry command

Full Usage: Command.retry maxAttempts delay shouldRetry command

Parameters:
Returns: Command

Run the command up to `maxAttempts` times in total (initial run plus retries), waiting `delay` between attempts (`0`/`1` both mean a single run). A negative `maxAttempts` or `delay` is rejected with `ArgumentOutOfRangeException`; delays beyond the maximum armable timer interval are clamped when the retry runs. If the predicate throws, the consuming verb returns `ProcessError.RetryPredicate` with the original attempt error in `Original`, and no further attempt runs.

maxAttempts : int
delay : TimeSpan
shouldRetry : ProcessError -> bool
command : Command
Returns: Command

Command.retryBackoff maxAttempts baseDelay factor maxDelay jitter shouldRetry command

Full Usage: Command.retryBackoff maxAttempts baseDelay factor maxDelay jitter shouldRetry command

Parameters:
Returns: Command

Run the command with exponential retry backoff: `baseDelay × factor^n`, capped at `maxDelay` before optional jitter. A negative `maxAttempts` is rejected with `ArgumentOutOfRangeException`; `0` and `1` both mean a single run. Retry timers use the command's `TimeProvider`. If the predicate throws, the consuming verb returns `ProcessError.RetryPredicate` with the original attempt error in `Original`, and no further attempt runs.

maxAttempts : int
baseDelay : TimeSpan
factor : float
maxDelay : TimeSpan
jitter : bool
shouldRetry : ProcessError -> bool
command : Command
Returns: Command

Command.retryNever command

Full Usage: Command.retryNever command

Parameters:
Returns: Command

Explicitly disable retrying for this command, overriding any inherited `Retry` policy (e.g. from a `CliClient.WithDefaults` template). The command always runs exactly once.

command : Command
Returns: Command

Command.rlimit resource soft hard command

Full Usage: Command.rlimit resource soft hard command

Parameters:
Returns: Command

Cap one Unix per-process resource for the child (`setrlimit(2)`): `soft` is the value in force, `hard` the ceiling the child may raise it back to, both in the resource's native unit (bytes, seconds, or a count). Different resources accumulate; the same one replaces in place. Unix-only: a set limit fails a Windows spawn with `ProcessError.Unsupported`, and a POSIX host without the util-linux `prlimit` helper fails with `ProcessError.ResourceLimit`. Combined with a whole-tree `ResourceLimits.CpuTimeMax`, the stricter CPU-time value wins. See `Command.Rlimit`.

resource : RlimitResource
soft : int64
hard : int64
command : Command
Returns: Command

Command.setsid command

Full Usage: Command.setsid command

Parameters:
Returns: Command

Detach the child into a new session (`setsid()`). Unix-only: a set request fails a Windows spawn with `ProcessError.Unsupported`. Containment is preserved. See `Command.Setsid`.

command : Command
Returns: Command

Command.stderr mode command

Full Usage: Command.stderr mode command

Parameters:
Returns: Command

Set how the child's standard error is connected.

mode : StdioMode
command : Command
Returns: Command

Command.stderrEncoding enc command

Full Usage: Command.stderrEncoding enc command

Parameters:
Returns: Command

Decode captured stderr with `encoding`.

enc : Encoding
command : Command
Returns: Command

Command.stderrLineTerminator terminator command

Full Usage: Command.stderrLineTerminator terminator command

Parameters:
Returns: Command

Frame captured/streamed stderr lines with `terminator` (default `LineTerminator.Lf`).

terminator : LineTerminator
command : Command
Returns: Command

Command.stderrTee sink command

Full Usage: Command.stderrTee sink command

Parameters:
Returns: Command

Copy raw captured stderr bytes to `sink`.

sink : Stream
command : Command
Returns: Command

Command.stderrToFile path append command

Full Usage: Command.stderrToFile path append command

Parameters:
    path : string
    append : bool
    command : Command

Returns: Command

Redirect the child's stderr straight to the file at `path` at the OS level — the stderr mirror of `stdoutToFile`. See `Command.StderrToFile`.

path : string
append : bool
command : Command
Returns: Command

Command.stdin source command

Full Usage: Command.stdin source command

Parameters:
Returns: Command

Feed the child's standard input from `source`. A one-shot source feeds at most one incarnation (see `Command.Stdin`).

source : Stdin
command : Command
Returns: Command

Command.stdinEncoding enc command

Full Usage: Command.stdinEncoding enc command

Parameters:
Returns: Command

Encode text sent to stdin with `encoding`.

enc : Encoding
command : Command
Returns: Command

Command.stdout mode command

Full Usage: Command.stdout mode command

Parameters:
Returns: Command

Set how the child's standard output is connected.

mode : StdioMode
command : Command
Returns: Command

Command.stdoutEncoding enc command

Full Usage: Command.stdoutEncoding enc command

Parameters:
Returns: Command

Decode captured stdout with `encoding`.

enc : Encoding
command : Command
Returns: Command

Command.stdoutLineTerminator terminator command

Full Usage: Command.stdoutLineTerminator terminator command

Parameters:
Returns: Command

Frame captured/streamed stdout lines with `terminator` (default `LineTerminator.Lf`).

terminator : LineTerminator
command : Command
Returns: Command

Command.stdoutTee sink command

Full Usage: Command.stdoutTee sink command

Parameters:
Returns: Command

Copy raw captured stdout bytes to `sink`.

sink : Stream
command : Command
Returns: Command

Command.stdoutToFile path append command

Full Usage: Command.stdoutToFile path append command

Parameters:
    path : string
    append : bool
    command : Command

Returns: Command

Redirect the child's stdout straight to the file at `path` at the OS level (no parent pump — the file outlives the parent). `append` chooses create/truncate (`false`) or append (`true`). Leaves no parent-side stdout stream, so it is rejected with `StdoutTee`/`OnStdoutLine`/`MergeStderr`/`Pty`. See `Command.StdoutToFile`.

path : string
append : bool
command : Command
Returns: Command

Command.stopSignal signal command

Full Usage: Command.stopSignal signal command

Parameters:
Returns: Command

Choose the soft signal used by graceful stop paths before hard-kill escalation.

signal : Signal
command : Command
Returns: Command

Command.streamBuffer policy command

Full Usage: Command.streamBuffer policy command

Parameters:
Returns: Command

Opt in to a bounded/backpressure channel for the streaming verbs (default stays unbounded).

policy : StreamBufferPolicy
command : Command
Returns: Command

Command.timeProvider provider command

Full Usage: Command.timeProvider provider command

Parameters:
Returns: Command

Use `timeProvider` for retry delays, readiness probes, `PtySession` pattern deadlines, and supervision.

provider : TimeProvider
command : Command
Returns: Command

Command.timeout duration command

Full Usage: Command.timeout duration command

Parameters:
Returns: Command

Kill the run `duration` after it was spawned.

duration : TimeSpan
command : Command
Returns: Command

Command.timeoutGrace grace command

Full Usage: Command.timeoutGrace grace command

Parameters:
Returns: Command

Terminate gracefully on timeout, force-killing only after `grace`.

grace : TimeSpan
command : Command
Returns: Command

Command.uid value command

Full Usage: Command.uid value command

Parameters:
Returns: Command

Run the child under this Unix user id (`setuid`). Unix-only: a set uid fails a Windows spawn with `ProcessError.Unsupported`; dropping needs privilege (else `ProcessError.Spawn`). See `Command.Uid`.

value : int
command : Command
Returns: Command

Command.umask mask command

Full Usage: Command.umask mask command

Parameters:
Returns: Command

Set the child's Unix file-mode creation mask (`umask(2)`). Unix-only: a set mask fails a Windows spawn with `ProcessError.Unsupported`. The default leaves the inherited umask untouched.

mask : int
command : Command
Returns: Command

Command.uncheckedInPipe command

Full Usage: Command.uncheckedInPipe command

Parameters:
Returns: Command

Inside a pipeline, allow this stage to exit non-zero without failing the pipeline.

command : Command
Returns: Command

Command.user uid gid command

Full Usage: Command.user uid gid command

Parameters:
    uid : int
    gid : int
    command : Command

Returns: Command

Run the child under this Unix user and group id (the privilege-drop pair). See `Command.User`.

uid : int
gid : int
command : Command
Returns: Command

Command.windowsCtrlSignals command

Full Usage: Command.windowsCtrlSignals command

Parameters:
Returns: Command

Windows: register a ConPTY child as the target for best-effort CTRL+BREAK through `ProcessGroup.Signal(Signal.Int/Term)`; ConPTY children already have process-group isolation. Regular children are put in a new process group. No effect on Unix. See `Command.WindowsCtrlSignals`.

command : Command
Returns: Command

Command.windowsIntegrityLevel level command

Full Usage: Command.windowsIntegrityLevel level command

Parameters:
Returns: Command

Lower the child's Windows mandatory integrity level, denying it write access to anything labelled above that level. Windows-only: a set request fails a POSIX spawn with `ProcessError.Unsupported`. See `Command.WindowsIntegrityLevel`.

level : WindowsIntegrityLevel
command : Command
Returns: Command

Command.windowsRawArg fragment command

Full Usage: Command.windowsRawArg fragment command

Parameters:
    fragment : string
    command : Command

Returns: Command

Append a trusted Windows command-line fragment verbatim after every ordinary argument. Never place untrusted input in `fragment`; a POSIX spawn and an automatically resolved batch wrapper return typed `Unsupported`.

fragment : string
command : Command
Returns: Command

Command.windowsRestrictedToken command

Full Usage: Command.windowsRestrictedToken command

Parameters:
Returns: Command

Run the child with a restricted token (`CreateRestrictedToken` + `DISABLE_MAX_PRIVILEGE`), keeping the caller's identity but none of its privileges. Windows-only: a set request fails a POSIX spawn with `ProcessError.Unsupported`. See `Command.WindowsRestrictedToken`.

command : Command
Returns: Command

Type something to start searching.