Read / write to screen in C / C ++

I was wondering how you can connect to the screen process in C / C ++, I often want the C program to listen to the output to this screen window and respond to this output, and also send some input to the program launched in this session. I just don’t know how I should connect to this screen session, and I did not find anything useful in my searches.

+4
source share
1 answer

It does exactly what you want. the screen will work inside the terminal device, so if (I assume you are connected to Linux) you want to create it programmatically, you need to configure the terminal pseudowire device using posix_openpt() , configure the slave device using grantpt()/unlockpt() , expanding, opening the slave pty in the child process, duplicating it on stdin / out / err and, finally, the execution screen with the corresponding parameters. Now you can send commands and receive notifications about terminals, as if you were a terminal emulator. See the pty(7) page for more information; I am pretty sure I missed some of them.

All this is a huge mess and almost certainly too complicated for what you are trying to do. So: what are you really trying to do?

+1
source

Source: https://habr.com/ru/post/1415675/


All Articles