diff --git a/src/core/Processes/ChildProcess.cs b/src/core/Processes/ChildProcess.cs index fff6f2a..c2a7285 100644 --- a/src/core/Processes/ChildProcess.cs +++ b/src/core/Processes/ChildProcess.cs @@ -89,19 +89,26 @@ internal ChildProcess(ChildProcessBuilder builder) _exited.SetResult(); }; - // If the child process might use the terminal, start it under the raw mode lock since we only allow starting - // non-redirected processes in cooked mode and we need to verify our current mode. - if (terminal) + try { - Terminal.System.StartProcess(() => + // If the child process might use the terminal, start it under the raw mode lock since we only allow + // starting non-redirected processes in cooked mode and we need to verify our current mode. + if (terminal) { - _ = _process.Start(); + Terminal.System.StartProcess(() => + { + _ = _process.Start(); - return this; - }); + return this; + }); + } + else + _ = _process.Start(); + } + catch (Win32Exception ex) + { + throw new ChildProcessException("Failed to start child process.", ex); } - else - _ = _process.Start(); Id = _process.Id;