WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Bash freezes when clicked

Open brnelsons opened this issue 10 years ago • 13 comments

  • While bash is running a command and the console window is clicked the output of the command stops and requires a ctrl+c to continue command output.
  • Bash should continue outputting and running a command regardless of something being selected or not.
  • Bash ~expects~ me to be attempting to copy text from the console when in fact I am giving the console window focus.
  • os build: 14393.321
  • Run a command, give focus to something other than the console, click inside the console window.

See our contributing instructions for assistance.

brnelsons avatar Oct 18 '16 19:10 brnelsons

This is how the Windows console works. It may change over the next year or so, but this is by design (although for legacy reasons).

fpqc avatar Oct 18 '16 20:10 fpqc

Yes, i know this is currently how the Windows Console works. But, it is a pain to work with and it should be improved. gnome-terminal in Ubuntu and other Linux distros is the perfect example of how a console window should behave.

Edit: This post should be marked as an improvement.

brnelsons avatar Oct 18 '16 21:10 brnelsons

@brnelsons They are working on it. The most detail we've gotten is in #111 if you want to read the posts of miniksa. Here is their in-office chart of console-related stuff: https://cloud.githubusercontent.com/assets/18221333/17521724/33f202b0-5e09-11e6-9c2a-e66931bb3a46.jpg

fpqc avatar Oct 18 '16 21:10 fpqc

An alternative is addingexport DISPLAY=:0; to the ~/.bashrc and running gnome-terminal from bash on windows. seems to work well. havent done much testing though...

brnelsons avatar Oct 18 '16 21:10 brnelsons

@brnelsons In the mean time, I suggest using wsltty.

fpqc avatar Oct 18 '16 21:10 fpqc

@fpqc I can currently use mintty through Git Bash terminal.

brnelsons avatar Oct 18 '16 21:10 brnelsons

Then all you need is the wslbridge by @rprichard

Compile and install in your cygwin environment.

fpqc avatar Oct 18 '16 21:10 fpqc

Yes. As @fpqc has said, this is the expected behavior, which is legacy from the DOS days. And yes, making it optional is definitely already on the feature backlog :)

zadjii-msft avatar Oct 18 '16 22:10 zadjii-msft

FWIW: winpty relies on this freezing behavior to atomically read the console screen buffer. It'd be great if Windows left in some way for winpty to continue working as-is. (Or, maybe, provide a proper public "server" API for consoles. The PowerShell OpenSSH project clearly needs such an API, too.)

winpty detects new lines by placing a vertical "marker" into one of the columns of the screen buffer, in the history/scrollback portion that isn't visible. Once the console window reaches the end of the buffer, each new line scrolls the marker up one line, so winpty can count the new lines by measuring how far the marker has moved upwards. winpty really needs the console output frozen while it's doing this work, though. It needs to:

  • Get the window, buffer, and cursor coordinates.
  • Search for the old marker, to determine how many lines may have changed. It does this by reading the entire marker column.
  • Read in all the lines that are visible or were visible during the last poll.
  • Write down a new marker when the old one has moved upward too much.

winpty is depending on undocumented Windows behavior, so I don't think Windows is ordinarily expected to preserve the behavior, but AFAIK, there's no better way to do what winpty does, and a bunch of programs are now using winpty (e.g. Visual Studio Code, IntelliJ, Eclipse).

If the option were configurable like other recent console options, I suppose winpty could ensure old behavior by creating an HKCU\Console\<path-to-winpty-agent.exe> entry, maybe.

rprichard avatar Oct 19 '16 00:10 rprichard

@rprichard If you read #111 It looks like they will be making a new console-reading API available in the future. I don't want to appear to commit the MS people to anything, but that might be a better solution in the future.

fpqc avatar Oct 19 '16 01:10 fpqc

winpty is depending on undocumented Windows behavior

Well I think you've really hit the nail on the head. There's a lot about the console that's undocumented behavior, but then someone somewhere depends on it, and then changing it, even if it's wrong, breaks someone somewhere.

That being said, we are working on a solution that we think everyone will be very happy with, but it's still a long while off. So be patient :)

zadjii-msft avatar Oct 19 '16 16:10 zadjii-msft

Thanks for the discussion.

Closing this issue since:

  1. This issue is actually an essential feature of the Windwos Console that is depended upon by MANY users. We tried disabling it once on internal builds and were nearly overrun by angry engineers with pitchforks and burning torches! We do, however, hear you and agree that it should be a configurable behavior, and so have added this ask to our internal feature tracking system and will consider implementing in a future build.
  2. This is the WSL issues repo, but this is an issue in Console which has its own Console GitHub Repo
  3. GitHub doesn't allow issues to be moved between repos, preserving posters' identity :(

If you have further asks/issues, please file new issues on our Console GitHub Repo.

bitcrazed avatar May 22 '18 22:05 bitcrazed

So can we also get the "Mark/Select" label in the terminal title when click for selecting is done?

HBelusca avatar May 24 '19 18:05 HBelusca