8000 Fix for Linux platform PowerShell exit on error during SSH remoting connection by PaulHigin · Pull Request #4993 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Fix for Linux platform PowerShell exit on error during SSH remoting connection #4993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1488,18 +1488,26 @@ private void CloseConnect 90D8 ion()
var stdErrReader = _stdErrReader;
if (stdErrReader != null) { stdErrReader.Dispose(); }

try
// The CloseConnection() method can be called multiple times from multiple places.
// Set the _sshProcessId to zero here so that we go through the work of finding
// and terminating the SSH process just once.
var sshProcessId = _sshProcessId;
_sshProcessId = 0;
if (sshProcessId != 0)
{
var sshProcess = System.Diagnostics.Process.GetProcessById(_sshProcessId);
if ((sshProcess != null) && !sshProcess.HasExited)
try
{
sshProcess.Kill();
var sshProcess = System.Diagnostics.Process.GetProcessById(sshProcessId);
if ((sshProcess != null) && (sshProcess.Handle != IntPtr.Zero) && !sshProcess.HasExited)
{
sshProcess.Kill();
}
}
catch (ArgumentException) { }
catch (InvalidOperationException) { }
catch (NotSupportedException) { }
catch (System.ComponentModel.Win32Exception) { }
}
catch (ArgumentException) { }
catch (InvalidOperationException) { }
catch (NotSupportedException) { }
catch (System.ComponentModel.Win32Exception) { }
}

private void StartErrorThread(
Expand Down
0