fix(ui): close the pseudo console when a conpty tile is disposed
This commit is contained in:
@@ -192,12 +192,24 @@ public sealed class PtyTerminalSession : IDisposable
|
||||
return (Task)s_sendToPty.Invoke(view, new object[] { data, CancellationToken.None })!;
|
||||
}
|
||||
|
||||
/// <summary>Kills the child and closes its pseudo console; falls back to a plain kill if the private seam is gone.</summary>
|
||||
public void Kill()
|
||||
{
|
||||
try { _control?.Kill(); }
|
||||
try
|
||||
{
|
||||
// TerminalControl.Kill() leaves the pseudo console open (one orphaned conhost.exe per tile);
|
||||
// only the private CleanupProcess disposes it, and BeginReparent suppressed its detach-time call.
|
||||
if (_control is { } control && s_terminalViewField?.GetValue(control) is TerminalView view && s_cleanupProcess is not null)
|
||||
s_cleanupProcess.Invoke(view, null);
|
||||
else
|
||||
_control?.Kill();
|
||||
}
|
||||
catch (Exception) { /* already exited */ }
|
||||
}
|
||||
|
||||
private static readonly MethodInfo? s_cleanupProcess =
|
||||
typeof(TerminalView).GetMethod("CleanupProcess", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
|
||||
Reference in New Issue
Block a user