ExecOptions Class
Options for a command executed inside a running container.
public sealed class ExecOptionsConstructors
| Name | Description |
|---|---|
| ExecOptions() |
ExecOptions()
ExecOptions.cspublic ExecOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| Command | Gets or sets the command and its arguments. The first element is the executable. |
| Detach | 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. |
| Environment | Gets the environment variables set for the command. |
| Privileged | Gets or sets a value indicating whether the command runs with every capability. Apple's container runtime does not support it. |
| StandardError | 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. |
| StandardInput | Gets or sets the input piped to the command's standard input. |
| StandardOutput | 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. |
| Timeout | 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. |
| Tty | 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. |
| User | Gets or sets the user to run the command as. |
| WorkingDirectory | Gets or sets the working directory inside the container. |
Command
ExecOptions.csGets or sets the command and its arguments. The first element is the executable.
Property value
Detach
ExecOptions.csGets 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
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.csGets the environment variables set for the command.
public IDictionary<string, string> Environment { get; }Property value
Privileged
ExecOptions.csStandardError
ExecOptions.csGets 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
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.csGets or sets the input piped to the command's standard input.
public InputSource? StandardInput { get; set; }Property value
StandardOutput
ExecOptions.csGets 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
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.
Timeout
ExecOptions.csGets 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
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
Remarks
A terminal merges the standard error into the standard output, and turns line feeds into \r\n.