microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.35k stars 815 forks source link

Stops running if the terminal isn't selected #431

Closed mkarpoff closed 7 years ago

mkarpoff commented 8 years ago

So if you run a long standing (ex. tar to untar large tar balls) command on bash and then deselect the terminal window (ie do something in the mean time) it will often stop until you re-select bash.

aseering commented 8 years ago

I have also observed this. I have not been able to reproduce it reliably, though.

I tried writing a simple shell script that outputs text on a regular interval. I've never seen it hang. I don't think it's due to writing to the console too quickly -- I've mostly observed it when doing large "apt-get install"'s, which generally print a line or a few lines per second.

benhillis commented 8 years ago

Is it possible that you're running into the “selected text” console behavior – if you accidentally select text with the mouse it will stop reading input which typically pauses the app trying to output.

zadjii-msft commented 8 years ago

I'm gonna agree with @benhillis on this one. Selecting the text can cause the output to pause, regardless of the focus of the console window.

aseering commented 8 years ago

I often have a two-monitor setup where I'm working on one monitor and have a bunch of random scripts and status-type windows that I have dragged over to the other monitor. On a couple occasions I've dragged a terminal over to the other monitor, watched it for a while, then gone back to work on my main monitor, and looked back some time later to notice a hang.

I suppose it's possible that my mouse strayed over to the wrong screen and that I clicked on it while I was over there. I'll pay attention next time. But if so, apparently that's a very easy mistake to make and not notice...

lateau commented 8 years ago

In my case, sometimes grunt watch and electron-prebuilt processes stop to work when my machine wake up from sleep/suspend. I can nothing with that consoles until force close them and reopen.

mredbishop commented 6 years ago

This still happens and it isn't limited to when the window loses focus. Frequently when doing long running apt-get upgrades or similar, the bash will pause until I press enter then resume. It's a real pain in the ass as I can't trust it to complete a long running task without user input.

Why was it closed, there is no way this is "by design"?

Unless I am missing something of course 😄

aseering commented 6 years ago

@mredbishop -- are you 100% sure that the window losing focus is the cause? Or could it be that you are clicking on the window itself (not the titlebar) to bring it in and out of focus (or just by mistake while it's out of focus)? And, as a result, accidentally selecting a few characters of text.

The Windows Console, by design, pauses command output while you are selecting text, so that you can select the text that you want and copy into the clipboard before it changes or scrolls by. This is actually a nice convenience if you need it. The problem is, most of the time you don't need it, and it's actually really easy to accidentally get the console window into text-selection mode by clicking on it.

mredbishop commented 6 years ago

I didn't know that! I'll observe the behaviour some more and find out. Thanks @aseering for the info 🙂

rks92 commented 6 years ago

Try turning quick edit mode off: Right Click on header > Properties > Options > Edit Options

Source: https://stackoverflow.com/questions/30418886/how-and-why-does-quickedit-mode-in-command-prompt-freeze-applications