GPG git commit - AllowSetForegroundWindow - Access is Denied #4207

Closed
opened 2026-01-30 23:40:59 +00:00 by claunia · 4 comments
Owner

Originally created by @ElectricHavoc on GitHub (Oct 1, 2019).

While watching the great @shanselman show off his shiny new terminal in dotnet community standup, we encountered an interesting use case. I've included the clip below.

Environment

Scott Hanselman's DotNet Machine

Steps to reproduce

Using gpg to sign commits, it throws an access denied error.

https://clips.twitch.tv/EsteemedColorfulVelociraptorSoBayed

Expected behavior

Some expected output shown from gpg in colors?

Actual behavior

gpg: AllowSetForegroundWindow(#) failed: Access is denied.

image

Originally created by @ElectricHavoc on GitHub (Oct 1, 2019). While watching the great @shanselman show off his shiny new terminal in dotnet community standup, we encountered an interesting use case. I've included the clip below. # Environment ```Scott Hanselman's DotNet Machine``` # Steps to reproduce Using gpg to sign commits, it throws an access denied error. https://clips.twitch.tv/EsteemedColorfulVelociraptorSoBayed # Expected behavior Some expected output shown from gpg in colors? # Actual behavior gpg: AllowSetForegroundWindow(#) failed: Access is denied. ![image](https://user-images.githubusercontent.com/3020276/65988253-794db680-e455-11e9-9318-2f4126b526a3.png)
claunia added the Needs-TriageIssue-BugNeeds-Tag-FixProduct-Terminal labels 2026-01-30 23:41:00 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Oct 1, 2019):

@shanselman why is this a Windows Terminal bug?

What's the real "expected behavior" here?

My totally uneducated guess is that gpg is using GetConsoleWindow to try and pop a dialog above the console window? Though, that's one of those APIs that we're just discouraging people from using, especially in ConPTY. #2988 is having a very similar discussion currently. I might be totally off base here.

@zadjii-msft commented on GitHub (Oct 1, 2019): @shanselman why is this a Windows Terminal bug? What's the real "expected behavior" here? My totally uneducated guess is that gpg is using GetConsoleWindow to try and pop a dialog above the console window? Though, that's one of those APIs that we're just discouraging people from using, especially in ConPTY. #2988 is having a very similar discussion currently. I might be totally off base here.
Author
Owner

@shanselman commented on GitHub (Oct 2, 2019):

@zadjii-msft It's a terminal bug because it works today in conhost/cmd.exe ;) It's a regression from "it worked before and now I use Terminal and it doesn't work." It's a pretty interesting bug.

To be clear, it literally makes signed git commits impossible with Windows Terminal. We can take it up with gpg but it's still a problem. If it's a Bad Thing (TM) then we could provide them with an example of the Right Way.

@shanselman commented on GitHub (Oct 2, 2019): @zadjii-msft It's a terminal bug because it works today in conhost/cmd.exe ;) It's a regression from "it worked before and now I use Terminal and it doesn't work." It's a pretty interesting bug. To be clear, it literally makes signed git commits impossible with Windows Terminal. We can take it up with gpg but it's still a problem. If it's a Bad Thing (TM) then we could provide them with an example of the Right Way.
Author
Owner

@zadjii-msft commented on GitHub (Oct 2, 2019):

Oh I'm more worried about the why it's a bug.

Does anyone know the right place to report this upstream?

We've already dealt with an issue like this, where msys2 tools where using GetConsoleWindow to check if the console was running in a headless/headed scenario. Previously, conpty just returned 0, which made them think they were running headless, and changed their behavior. So we created a fake HWND for them to be able to use.

@shanselman Out of curiosity, does this repro if you try running the same command in cmd.exe/powershell.exe/pwsh.exe from within WSL? Running those Windows exe's from w/in WSL will activate conpty mode with conhost.exe as the Terminal. If it does repro there, then we can be sure it's a conpty bug, and not (somehow) a Terminal bug.

@zadjii-msft commented on GitHub (Oct 2, 2019): Oh I'm more worried about the _why_ it's a bug. Does anyone know the right place to report this upstream? We've already dealt with an issue like this, where msys2 tools where using _GetConsoleWindow_ to check if the console was running in a headless/headed scenario. Previously, conpty just returned 0, which made them think they were running headless, and changed their behavior. So we created a fake HWND for them to be able to use. @shanselman Out of curiosity, does this repro if you try running the same command in cmd.exe/powershell.exe/pwsh.exe from within WSL? Running those Windows exe's from w/in WSL will activate conpty mode with conhost.exe as the Terminal. If it does repro there, then we can be sure it's a conpty bug, and not (somehow) a Terminal bug.
Author
Owner

@zadjii-msft commented on GitHub (Oct 3, 2019):

Hey so @shanselman and I spoke on the phone recently, and we actually couldn't repro this again 😆

Considering the breadth of issues posted elsewhere on the web that pre-date the Terminal, it seems like this particular error message is actually unrelated to the Terminal after all.

Thanks for the bug report!

@zadjii-msft commented on GitHub (Oct 3, 2019): Hey so @shanselman and I spoke on the phone recently, and we actually couldn't repro this again 😆 Considering the breadth of issues posted elsewhere on the web that pre-date the Terminal, it seems like this particular error message is actually unrelated to the Terminal after all. Thanks for the bug report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4207