If I have a (compiled) background process (on GNU/Linux) such as a daemon create a pseudo-tty for itself, using openpty() or similar, is there a way to connect to it from the shell, for example to open a command line oriented interface (e.g. for debugging / re-configuring it on the fly).
This is very similar to what is asked here:
How to create pty that is connectable by Screen app in Linux
Someone suggests an answer where they connect to it using screen and minicom but it is not that clear to me how. I had assumed screen could only connect to screens created by screen.
Ideally I want to either use standard command line tools to connect to the daemon or provide a lightweight program that does the necessary.
The aim is for something simpler than going for a full scale client server implementation (and to play with ttys).
This is a cut-down version of https://stackoverflow.com/questions/65150035/attach-a-terminal-to-a-process-running-as-a-daemon-to-run-an-ncurses-ui?noredirect=1#comment115179806_65150035 which is a bit more vague.
My original question was closed as lacking a clear focus. I have a replacement here:
attach a terminal to a process running as a daemon (to run an ncurses UI)
This question focuses on one aspect of the use case described. If I had an application running in its own pty is there a way of linking that tty to an existing terminal session.
Effectively the application is 'backgrounded' but running in a hidden terminal. How would you make your terminal connect to that 'backgrounded' one.
I think you need something like:
- a select loop forwarding stdin and stdout to the master end of the pty
- forwarding of SIGWINCH to the pty to adjust its size to match your terminal (or visa versa).