Skip to content

Commit

Permalink
Turn Win32Exception from ChildProcess.Start() into ChildProcessExcept…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
alexrp committed Jan 8, 2024
1 parent f0d7337 commit 443c098
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/core/Processes/ChildProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 443c098

Please sign in to comment.