microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
94.74k stars 8.2k forks source link

DISCUSSION: An example of running terminal (either Windows Terminal, or conhost) attached to pseudo console #8819

Open vvavrychuk opened 3 years ago

vvavrychuk commented 3 years ago

I would like to feed/consume pseudo console pipes from my application and have some terminal (either Windows Terminal, or conhost) connected to this pseudo console. This is almost like https://github.com/microsoft/terminal/tree/main/samples/ConPTY/EchoCon but a little bit reversed. In EchoCon, application that feeds pseudo console (ping) is running as a separate process and current process is assumed to be run from terminal. But I want current process to feed pseudo console (current process can be run from terminal or not, it should not matter), and some terminal should be run from my application connected to pseudo console in a separate window.

The background is that I am porting application from Linux which uses multiple pseudo-consoles in one process. It is reading and writing to/from them in one thread sequentially. And it spawns multiple xterms connected to those pseudo consoles.

If I create multiple Windows pseudo consoles in one process, how can I spawn multiple terminal applications (conhost.exe?, Windows Terminal) to output content of those pseudo consoles?

zadjii-msft commented 3 years ago

Okay so it might be helpful to have additional terminology defined here.

So it sounds like you have a client app that needs to output to multiple terminals all at once, correct? Kinda like a reverse tmux, correct? We can try helping come up with a clever solution, but I want to make sure we understand the scenario fully.

ghost commented 3 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

vvavrychuk commented 3 years ago

@zadjii-msft you are absolutely right!

I have tried to code example here https://github.com/vvavrychuk/multipty-example/blob/master/multipty.c

It opens given number of ptys and launches xterm for each using -S flag. If user types something in xterm, it returns back to main application Screenshot from 2021-01-25 01-06-16

There should be also a way to type client id and message in main application and it will be sent to corresponding client, but that's not finished in this example.

Also, I should probably use non-buffered IO...

DHowett commented 3 years ago

I'm going to take triage off this, but keep it open as a discussion question. :smile: Thanks!