GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing github.com — Fix for Linux platform PowerShell exit on error during SSH remoting connection by PaulHigin · Pull Request #4993 · PowerShell/PowerShell Conversation
Contributor
This fixes addresses issue #4940. The problem is that the connection clean up code in SSHClientSessionTransportManager would try to terminate a process with id == 0, which is the initial value for the _sshProcessId field when no SSH process has been created yet. For both Linux and Windows platforms process id of zero is a special process and should not be terminated. Fortunately those processes are not terminated by the existing code but on Linux platforms the PowerShell parent process exits immediately. The fix is to add checks that the SSH process has been created and is valid before terminating it during connection cleanup.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Paul Higinbotham (PaulHigin)
requested review from
Dan Travison (dantraMSFT) and
Mike Richmond (mirichmo)
as code owners
Dan Travison (dantraMSFT)
approved these changes
|
| if (stdErrReader != null) { stdErrReader.Dispose(); } | ||
|
|
||
| try | ||
| var sshProcessId = _sshProcessId; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can't you use _sshProcessId directly instead of creating a new variable?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
CloseConnection can be called from multiple places (state machine, error handling) and this is just to prevent going through this code path multiple times. I am not concerned about race conditions since Process type is thread safe ... I just want to prevent running the code path after the process has been terminated.
I'll add a comment to clarify.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| try | ||
| var sshProcessId = _sshProcessId; | ||
| _sshProcessId = 0; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Perhaps initialize it to 0 in the constructor instead of resetting it here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
CLR guarantees all fields are initialized to zero. I am setting it back to zero here to prevent the code path running twice (see comment above).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…onnection (PowerShell#4993) * Fix for Linux platform PowerShell exit on error during SSH remoting connection * Added comment for clarification per code review request
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.