-
Notifications
You must be signed in to change notification settings - Fork 167
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
Ctrl-C handling is inadequate for interactive cmd and PowerShell #116
Comments
Yeah, I've noticed this before. I think synthesizing Ctrl-C requires more than just calling I wonder if winpty should synthesize Ctrl-C GUI events, like it does for WSL navigation keys. |
It looks like ConEmu also takes the send-a-GUI-message route.
if (lbProcessEvent)
{
// Issue 590: GenerateConsoleCtrlEvent does not break ReadConsole[A|W] function!
SetLastError(0);
LRESULT lSendRc =
SendMessage(ghConWnd, WM_KEYDOWN, r.Event.KeyEvent.wVirtualKeyCode, 0);
DWORD nErrCode = GetLastError();
msprintf(szLog, countof(szLog), L" --- CtrlC/CtrlBreak sent (%u,%u)", LODWORD(lSendRc), nErrCode);
LogString(szLog);
} |
I noticed a related issue: #117 |
Thanks a lot, really, but it's only partial success. |
I can just reopen this issue. Can you provide more details? It's working with both CMD and PowerShell for me. e.g. I type some text into at the PowerShell prompt, then press Ctrl-C, and it moves to the next line. I'm testing on Windows 7, though -- maybe I should look at Windows 10. |
OK, it's broken on Windows 10 v15063. It just adds a ^C to the end of the line. |
Correct. I can test against a Windows Server 2016 in a couple of hours. Or there's no need? |
Probably not necessary, I've found something that's obviously wrong, but I'm wondering why I got it wrong. I think I'll have it fixed in a few hours / a day or two. i.e For Ctrl-C, winpty is generating:
The normal console generates:
I bet that fixing the discrepancy will fix the PowerShell problem. |
i.e. The issue is that winpty isn't matching what Windows would use in a |
The exact same situations happens in WinXP, so it's not a new bug. I probably didn't notice it, because most programs use Here's one way to fix the bug:
Maybe I'll remove the |
I tried reusing the GUI-message code path for unprocessed Ctrl-C, but the character code was always NUL, and PowerShell didn't work. The diff I posted should work, though. |
Let me know if my change fixed it. It worked for me on Windows 10. |
Well, I've tested the current HEAD (
|
I reverted the first part of this issue's fix -- winpty uses What I expect now:
I don't really know how Windows' input handling works -- I'll describe what I think happens. When an event like I tried using I noticed that the The existing use of As a compromise, maybe a winpty user can indicate that they're using winpty in the foreground, and then winpty can use |
Whoa, that's a lot to process. Will do during spare time. |
Hi, I hope this helps.. I tried to winpty use in GitSCM (bash on MINGW32) and it works well. $ winpty --version $ winpty winpty-agent.exe --show-input Press any keys -- Ctrl-D exits |
I fixed this here - my understanding of it is unprocessed mode needs both the |
I think MS is going to have to solve this one, hopefully whatever they do will work here too - PowerShell/Win32-OpenSSH#914 |
I think I figured this one out. In processed mode, I consider this a cmd.exe bug and not a bug in winpty, node-pty, or any dependent project, and I'm not sure if there's a feasible workaround in all cases, but if there is I think it's worth implementing. I'm not familiar with the restrictions on background desktops - does anyone know if it's possible to |
As @parkovski mentioned it seems to be fixed in the If you're unsure what terminal is used you can see it in the terminal drop-down menu. You can launch the integrated console without opening a ps1 file from the command panel. Press Unfortunately, the problem still persists in the PowerShell Version
vscode version
Cheers, |
Quickly skimming over the PowerShell editor services libraries, it looks like that's because the integrated console handles |
Hey @rprichard! Is 0.44 far off? There's a bunch of us hanging for the fix to be included in our favorite win-pty projects 🙂 |
This change reverts the first part of the rprichardGH-116 fix. See rprichard#116
I'd like to add one passing note -- I think it's an additional symptom of the problem being discussed here. I'm running |
If I use a combination of Cygwin + OpenSSH + WinPTY to run interactive
cmd
or PowerShell they don't treat Ctrl-C as a command input cancellation.Ctrl-C works for command abort, so this is not a pressing issue. Just an annoyance due to my keyboard skills.
I've reviewed Ctrl-C handling (the one with
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0))
and I have no idea what is wrong. But I'm not a Win32 API specialist.The text was updated successfully, but these errors were encountered: