ExecOptions Class

Options for a command executed inside a running container.

public sealed class ExecOptions

Constructors

NameDescription
ExecOptions()

ExecOptions()

ExecOptions.cs
public ExecOptions()

No documentation is available.

Properties

NameDescription
CommandGets or sets the command and its arguments. The first element is the executable.
DetachGets or sets a value indicating whether the command is started in the background. TemporaryContainer.ExecAsync returns as soon as it is started, with an exit code of 0 and no output, and the command keeps running.
EnvironmentGets the environment variables set for the command.
PrivilegedGets or sets a value indicating whether the command runs with every capability. Apple's container runtime does not support it.
StandardErrorGets or sets the stream the standard error of the command is copied to, byte for byte. When it is set, ExecResult.StandardError is empty.
StandardInputGets or sets the input piped to the command's standard input.
StandardOutputGets or sets the stream the standard output of the command is copied to, byte for byte. When it is set, ExecResult.StandardOutput is empty.
TimeoutGets or sets the maximum time to wait for the command. When it elapses, TemporaryContainer.ExecAsync throws a TimeoutException. null waits until the command exits or the cancellation token is canceled.
TtyGets or sets a value indicating whether the command runs in a pseudo-terminal. Some commands only print colors or progress, or only behave interactively, in a terminal.
UserGets or sets the user to run the command as.
WorkingDirectoryGets or sets the working directory inside the container.

Gets or sets the command and its arguments. The first element is the executable.

public IList<string> Command { get; set; }

Property value

IList<string>

Gets or sets a value indicating whether the command is started in the background. TemporaryContainer.ExecAsync returns as soon as it is started, with an exit code of 0 and no output, and the command keeps running.

public bool Detach { get; set; }

Property value

bool

Remarks

A detached command cannot have a ExecOptions.StandardInput, a ExecOptions.StandardOutput, a ExecOptions.StandardError or a ExecOptions.Timeout. The wslc runtime does not support it and throws a NotSupportedException.

Environment

ExecOptions.cs

Gets the environment variables set for the command.

public IDictionary<string, string> Environment { get; }

Privileged

ExecOptions.cs

Gets or sets a value indicating whether the command runs with every capability. Apple's container runtime does not support it.

public bool Privileged { get; set; }

Property value

bool

StandardError

ExecOptions.cs

Gets or sets the stream the standard error of the command is copied to, byte for byte. When it is set, ExecResult.StandardError is empty.

public Stream? StandardError { get; set; }

Property value

Stream?

Remarks

The stream is not disposed. When ExecOptions.Tty is set, the command writes both outputs to the terminal, and everything goes to the standard output.

StandardInput

ExecOptions.cs

Gets or sets the input piped to the command's standard input.

public InputSource? StandardInput { get; set; }

Property value

InputSource?

StandardOutput

ExecOptions.cs

Gets or sets the stream the standard output of the command is copied to, byte for byte. When it is set, ExecResult.StandardOutput is empty.

public Stream? StandardOutput { get; set; }

Property value

Stream?

Remarks

Use it for binary output, such as the output of pg_dump or tar, which decoding it as text would corrupt, or for an output too large to keep in memory. The stream is not disposed.

Gets or sets the maximum time to wait for the command. When it elapses, TemporaryContainer.ExecAsync throws a TimeoutException. null waits until the command exits or the cancellation token is canceled.

public TimeSpan? Timeout { get; set; }

Property value

TimeSpan?

Remarks

The runtimes cannot stop a command they started without a terminal: the command may keep running in the container after the timeout.

Gets or sets a value indicating whether the command runs in a pseudo-terminal. Some commands only print colors or progress, or only behave interactively, in a terminal.

public bool Tty { get; set; }

Property value

bool

Remarks

A terminal merges the standard error into the standard output, and turns line feeds into \r\n.

Gets or sets the user to run the command as.

public string? User { get; set; }

Property value

string?

WorkingDirectory

ExecOptions.cs

Gets or sets the working directory inside the container.

public string? WorkingDirectory { get; set; }

Property value

string?