Skip to content

Commit

Permalink
Add Windows1809 workaround to termination on dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
asmichi committed Sep 8, 2021
1 parent e188ec9 commit f14e0a0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ChildProcess/ProcessManagement/WindowsChildProcessState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Asmichi.ProcessManagement
{
internal class WindowsChildProcessState : IChildProcessStateHolder, IChildProcessState
{
// The exit code to be passed to TerminateProcess.
// The exit code to be passed to TerminateProcess (same as Process.Kill).
private const int TerminateProcessExitCode = -1;
// ASCII code of Ctrl+C: 'C' - 0x40
private const int CtrlCCharacter = 0x03;
Expand Down Expand Up @@ -49,7 +49,15 @@ public void Dispose()

if (!_isPseudoConsoleDisposed)
{
// This will terminate the process tree (unless we are on Windows 1809).
_pseudoConsole?.Dispose();

if (WindowsVersion.NeedsWorkaroundForWindows1809)
{
// Should always succeed.
Kill();
}

_isPseudoConsoleDisposed = true;
}
}
Expand Down

0 comments on commit f14e0a0

Please sign in to comment.