dwmkerr / consolecontrol

ConsoleControl is a C# class library that lets you embed a console in a WinForms or WPF application.
MIT License
723 stars 169 forks source link

Is it possible to open Ubuntu subsystem? #52

Open Bartiik opened 4 years ago

Bartiik commented 4 years ago

Hey, same as in the title, do you know the way to open the Ubuntu subsystem, if it's been installed on my PC? I cannot find the proper process to type in Console.StartProcess and parameters. Thanks for any help :)

dwmkerr commented 4 years ago

I'm afraid I don't think it is possible. The reason I think this is the case is when I look at Ubuntu under the WSL, it looks like this:

image

Now I'm not getting exactly the details I'd need to confirm this, but I believe that what is happening here is that the conhost program is actually running a wsl process, which is itself hosting ubuntu. This means that ubuntu is not simply an app with a stdin and stdout which we can pipe data to and from, it really does need to be hosted in the conhost environment.

However, by inspecting where the ubuntu executable actually is, then running cmd then running the ubuntu executable - I get this:

image

Now unless I am mistaken, what I'm seeing here is actually bash telling me that it doesn't recognise commands like ls\r - which makes sense, because I'm on windows - so when I hit enter, bash sees ls\r\n - linux only needs the \n as a linefeed (Windows uses carriage return then linefeed).

So it looks suspiciously like it might work with a bit of tweaking (I forget, but I think running cmd will create a conhost process, but it's been a while since I looked into the internals) but in it's current state, it's not supported I'm afraid