xilun / cbwin

Launch Windows programs from "Bash on Ubuntu on Windows" (WSL)
Other
327 stars 25 forks source link

interactive win32 console programs are broken (input and output) #39

Closed xilun closed 7 years ago

xilun commented 7 years ago

(Output breakage is actually also seen in some non-interactive win32 console programs.)

It can probably be fixed in a lot of cases by a few calls of GetConsoleMode() and SetConsoleMode().

In case of concurrent executions there might be no perfect way to do it, but I guess something that works most of the time can be good enough.

xilun commented 7 years ago

The general idea would be to:

We will default to support interactive win32 programs, and maybe add a flag to keep stdin alone (for batch works). IMO this choice is better than adding a flag for interactive usage just to keep Ctrl-Z working by default on e.g. builds. However, if this really breaks Ctrl-Z, some people who might have taken the habit of Ctrl-Z'ing GUI programs, then bg them (because they use to do that under a GNU/Linux system) might be irritated by such breakage. That's one more argument if favor of detection of Win32 GUI programs.

xilun commented 7 years ago

commit ab86dc8

Unfortunately this does not fix all the issues in the AU edition (maybe because of issues in WSL/Console implementation?), but it works quite well in the last Insider build 14946

The wcmd echo. workaround also is not needed anymore.

xilun commented 7 years ago

However, Ctrl-C while running e.g. wcmd dir /s c:\\ now kills the whole console. I will try to avoid that...

xilun commented 7 years ago

I think there are several steps needed to handle Ctrl-C "properly":

  1. setup a handler in outbash (we cannot just ignore it, because that would be inherited by all children processes)
  2. start bash.exe in a way that makes it ignore Ctrl-C
  3. launch wanted programs in another way to keep Ctrl-C effective for them
xilun commented 7 years ago

ctrl-c fixed by 771616d closing this ticket to document remaining issues more clearly