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
|
|
|
|
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`.
|
|
|
|
|
Full Usage:
Command.cancelOn cancellationToken command
Parameters:
CancellationToken
command : Command
Returns: Command
|
Also cancel the run when `cancellationToken` fires.
|
|
|
Full Usage:
Command.capturePolicy policy command
Parameters:
ICapturePolicy
command : Command
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`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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`.
|
|
|
|
|
Full Usage:
Command.ioPriority level command
Parameters:
IoPriority
command : Command
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`.
|
|
|
|
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`.
|
Full Usage:
Command.killOnParentDeathScope command
Parameters:
Command
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`.
|
Full Usage:
Command.lineTerminator terminator command
Parameters:
LineTerminator
command : Command
Returns: Command
|
Frame both captured/streamed streams' lines with `terminator` (default `LineTerminator.Lf`).
|
|
|
|
|
|
|
|
|
|
|
Full Usage:
Command.outputBuffer policy command
Parameters:
OutputBufferPolicy
command : Command
Returns: Command
|
Bound the in-memory backlog of captured lines.
|
|
|
|
|
|
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`.
|
|
|
|
|
Full Usage:
Command.retry maxAttempts delay shouldRetry command
Parameters:
int
delay : TimeSpan
shouldRetry : ProcessError -> bool
command : Command
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.
|
Full Usage:
Command.retryBackoff maxAttempts baseDelay factor maxDelay jitter shouldRetry command
Parameters:
int
baseDelay : TimeSpan
factor : float
maxDelay : TimeSpan
jitter : bool
shouldRetry : ProcessError -> bool
command : Command
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.
|
|
|
Full Usage:
Command.rlimit resource soft hard command
Parameters:
RlimitResource
soft : int64
hard : int64
command : Command
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`.
|
|
|
|
|
|
|
Full Usage:
Command.stderrLineTerminator terminator command
Parameters:
LineTerminator
command : Command
Returns: Command
|
Frame captured/streamed stderr lines with `terminator` (default `LineTerminator.Lf`).
|
|
|
|
|
|
|
|
|
|
|
|
|
Full Usage:
Command.stdoutLineTerminator terminator command
Parameters:
LineTerminator
command : Command
Returns: Command
|
Frame captured/streamed stdout lines with `terminator` (default `LineTerminator.Lf`).
|
|
|
|
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`.
|
|
|
Full Usage:
Command.streamBuffer policy command
Parameters:
StreamBufferPolicy
command : Command
Returns: Command
|
Opt in to a bounded/backpressure channel for the streaming verbs (default stays unbounded).
|
Full Usage:
Command.timeProvider provider command
Parameters:
TimeProvider
command : Command
Returns: Command
|
Use `timeProvider` for retry delays, readiness probes, `PtySession` pattern deadlines, and supervision.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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`.
|
Full Usage:
Command.windowsIntegrityLevel level command
Parameters:
WindowsIntegrityLevel
command : Command
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`.
|
|
|
|
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`.
|
ProcessKit API Reference