When running the initializer script, it runs it in a secondary pwsh instance to prevent the main script from hanging. However, you can't fully kill it from the parent process, because the second script spawns a third mystery powershell instance that doesn't die when you kill the second one... Gotta find a work around to prevent leaks in my scripts :(
Finding the Cause:
- Start Point: PowerShell-Quick-Tray/initialize.pses.server.ps1
- $PSES_BUNDLE_PATH/PowerShellEditorServices/Start-EditorServices.ps1
- Gist of the referenced file: [gist]
- Import-Module -Name "$PSScriptRoot/PowerShellEditorServices.psd1"
- Gist of the referenced file: [gist]
- [line from gist]:
RootModule = if ($PSEdition -eq 'Core') { 'bin/Core/Microsoft.PowerShell.EditorServices.Hosting.dll' } else { 'bin/Desktop/Microsoft.PowerShell.EditorServices.Hosting.dll' }
These are good DLLs to possible look at
- Start-EditorServices @PSBoundParameters
Couldn't find it at the moment. Trying to increase logging verbosity.
Here are the valid values for loglevel:
It is also possible that the only way to shutdown the app is via LSP message
Running this code from stackoverflow to get child PIDs of the second powershell instance reveals the PID of the third one, but also reveals that it also spawned a conhost instance.
Gonna try using this process tree killer to kill the server:
https://stackoverflow.com/questions/55896492/terminate-process-tree-in-powershell-given-a-process-id
Ha, ha, ha... lol I'm an idiot
My script starting the Editor Services is another call to pwsh. I'm an idiot.
Also, fun fact. This was staring me in the face the whole time:
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.