-
Notifications
You must be signed in to change notification settings - Fork 166
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
winpty-agent.exe hangs on Windows 10 upon terminal resize #31
Comments
Confirm: that fixes the hang on Windows 10. |
Could someone post that as a pull request? Pleaaaase. |
I think I understand what's happening. The new Windows 10 console rewraps the console lines when the console is resized. When the console is "frozen" (i.e. the "Select All" system command is active), writes to the console block. Presumably, with Windows 10, attempts to resize the console also block. I really need to test with Windows 10, though. I'm wondering what happens if one of the console programs prints new lines before/during the Win32Console::reposition call. I suspect Windows 10's line rewrapping is going to confuse winpty. Normally, winpty tries to detect changes and send only changed lines, but with rewrapping, I think it's going to lose track of what's new. |
No, it doesn't, but the selection is cleared. This is different to a Windows 7 console.
I wonder what freezing the console during the reposition should actually protect. Printing lines does not affect window or buffer size.
The only bad impact I have seen so far is, that a resize confuses editing of the current input line in cmd.exe, in particular history navigation. It seems to work fine with e.g. bash (+readline). |
I tested programmatically resizing the console buffer while selection was in-progress, and it apparently hangs the Windows console, such that the conhost.exe process must be killed from the Task Manager. This actually seems like a Windows bug to me. See https://github.com/rprichard/winpty/blob/win10/misc/Win10ResizeWhileFrozen.cc |
I reported the conhost.exe hang to Microsoft: https://wpdev.uservoice.com/forums/266908-command-prompt/suggestions/9941292-conhost-exe-hangs-in-win10-if-setconsolescreenbuff |
…ing. * Unfreeze the console while changing the buffer size. Changing the buffer size hangs conhost.exe. See: - #31 - https://wpdev.uservoice.com/forums/266908-command-prompt/suggestions/9941292-conhost-exe-hangs-in-win10-if-setconsolescreenbuff * Detect buffer size changes and switch to a "direct mode". Direct mode makes no attempt to track incremental console changes. Instead, the content of the current console window is printed. This mode is intended for full-screen apps that resize the console. * Reopen CONOUT$, which detects apps that change the active screen buffer. Fixes #34. * In the scroll scraping (scrollingScrapeOutput), consider a line changed if the new content is truncated relative to the content previously output. Previously, we only compared against the line-buffer up to the current console width. e.g. If this: |C:\Program| turns into: |C:\Prog| |ram | we previously left |C:\Program| in the line-buffer for the first line and did not re-output the first line. We *should* reoutput the first line at this point so that, if the line scrolls upward, and the terminal is later expanded, we will have output an "Erase in Line" CSI command to clear the obscured "ram" text. We need to update the line-buffer for the sake of Windows 10 combined with terminals like xterm and putty. On such a terminal, if the terminal later widened, Windows 10 will restore the console to the first state. At that point, we need to reoutput the line, because xterm and putty do not save and restore truncated line content extending past the current terminal width.
Fixed by d464089. Unfortunately, conhost.exe can still hang if something other than winpty resizes the console. |
E.g. within mintty, execute
then resize the terminal window -> winpty-agent.exe hangs in
Workaround: Enable legacy console in cmd > Properties.
The following patch seems to prevent the hang:
The text was updated successfully, but these errors were encountered: