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.
Scott Hanselman's DotNet Machine
Using gpg to sign commits, it throws an access denied error.
https://clips.twitch.tv/EsteemedColorfulVelociraptorSoBayed
Some expected output shown from gpg in colors?
gpg: AllowSetForegroundWindow(#) failed: Access is denied.

@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 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.
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.
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!
Most helpful comment
@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.