-
-
Notifications
You must be signed in to change notification settings - Fork 811
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
Improve pageant process handling #211
Conversation
It's supposed to be a background service style process, so this otherwise waits indefinitely. Suspect this is true for other `$sshAgent`s too (see a few lines below) but have no test cases so haven't changed it.
Do we actually end up waiting for pageant? It always returns immediately for me, even if it's asking for a key to be unlocked. Some quick testing timing the options for launching pageant looks like there's not much difference. |
@@ -303,7 +303,7 @@ function Start-SshAgent([switch]$Quiet) { | |||
$pageant = Get-Command pageant -TotalCount 1 -Erroraction SilentlyContinue | |||
$pageant = if ($pageant) {$pageant} else {Guess-Pageant} | |||
if (!$pageant) { Write-Warning "Could not find Pageant."; return } | |||
& $pageant | |||
Start-Process -NoNewWindow $pageant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace czar has come to visit - extra space here.
Is the waiting indefinitely an artifact of the instance already running? |
I don't think makes a difference, since an existing process would have caused |
I've updated the description with an explanation of what I'm seeing. |
I'm not a Pageant user, so I'll defer to whatever you come up with. I don't see a down-side to switching from |
I briefly thought it might not work in Powershell 2.0 and below due to not being in these docs. Turns out the docs are just somewhere else. |
No downsides and fixes issues, let's get this merged. |
Improve pageant process handling
💯 |
Don't wait indefinitely for pageant (given that it's a service-like process that adds a tray icon and waits for input), and don't error when there are already 2 pageant processes.
Hanging bug
This is the old behaviour I observed (that I believe f28bb54 removes):
Start state:
$env:GIT_SSH = "plink"
Repro:
Start-Process powershell.exe
which creates a new powershell window, starts pageant, then hangs forever (waiting for it to return).Start-Process powershell.exe
in my original powershell window which starts fine since pageant is already runningMultiple-pageant bug
When using GitExtensions on my machine I end up with two pageant processes (one is created by ShimGen), 99021d4 fixes the powershell error thrown in Start-SshAgent due to having an array returned. Stop-SshAgent also uses this, so should work with multiple pageant processes, but you need to call Stop-SshAgent once for each running SshAgent process which could be better, but is an improvement over doing nothing and erroring.