| 1 | # ProcessSettings |
| 2 | |
| 3 | Configures a process before start. |
| 4 | |
| 5 | ```csharp |
| 6 | public sealed class ProcessSettings |
| 7 | { |
| 8 | public string WorkingDirectory { get; set; } |
| 9 | public IList<string> CommandLine { get; set; } |
| 10 | public IDictionary<string, string> EnvironmentVariables { get; set; } |
| 11 | public ProcessOutputMode OutputMode { get; set; } |
| 12 | } |
| 13 | ``` |
| 14 | |
| 15 | Notes: |
| 16 | |
| 17 | - `CommandLine` must be non-empty before calling `Process.Start()`. |
| 18 | - The init process is started by `Container.Start()`, not by `Process.Start()`. |
| 19 | - `OutputMode.Event` enables `OutputReceived` / `ErrorReceived`. |
| 20 | - `OutputMode.Stream` enables `GetOutputStream(...)`. |
| 21 | |
| 22 | Example: |
| 23 | |
| 24 | ```csharp |
| 25 | var processSettings = new ProcessSettings |
| 26 | { |
| 27 | WorkingDirectory = "/workspace", |
| 28 | CommandLine = new List<string> { "/bin/sh", "-c", "env | sort" }, |
| 29 | EnvironmentVariables = new Dictionary<string, string> |
| 30 | { |
| 31 | ["DEMO"] = "1", |
| 32 | ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 33 | }, |
| 34 | OutputMode = ProcessOutputMode.Event |
| 35 | }; |
| 36 | ``` |
| 37 | |
| 38 | --- |