Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: add tty mux functionality to chroot2 #4163

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

europaul
Copy link
Contributor

This commit adds the ability to control the container's entrypoint process from multiple tty consoles. Mainly it's done to support the simultanious access to the container's console from the serial terminal and the VNC console.

The chroot2 script now accepts two additional argument which are the names of the tty consoles (serial and VNC) to be multiplexed. The script accepts inputs from both consoles and forwards them to the container's entrypoint stdin. The output from the container's entrypoint stdout and stderr is also multiplexed to both consoles. Additionally both consoles forward the common signals such as Ctrl+C, Ctrl+Z, Ctrl+, Ctrl+D to the container's entrypoint process.

This commit adds the ability to control the container's entrypoint
process from multiple tty consoles. Mainly it's done to support the
simultanious access to the container's console from the serial terminal
and the VNC console.

The `chroot2` script now accepts two additional argument which are the
names of the tty consoles (serial and VNC) to be multiplexed. The script
accepts inputs from both consoles and forwards them to the container's
entrypoint stdin. The output from the container's entrypoint stdout and
stderr is also multiplexed to both consoles. Additionally both consoles
forward the common signals such as Ctrl+C, Ctrl+Z, Ctrl+\, Ctrl+D to the
container's entrypoint process.

Signed-off-by: Paul Gaiduk <[email protected]>
@christoph-zededa
Copy link
Contributor

christoph-zededa commented Aug 26, 2024

I fear with this approach https://linux.die.net/man/1/isatty will return false - have you tried it?

@europaul
Copy link
Contributor Author

I fear with this approach https://linux.die.net/man/1/isatty will return false - have you tried it?

yes, tty for sure returns not a tty. is this a problem however?

@christoph-zededa
Copy link
Contributor

christoph-zededa commented Aug 26, 2024

I fear with this approach https://linux.die.net/man/1/isatty will return false - have you tried it?

yes, tty for sure returns not a tty. is this a problem however?

Lots of tools check on that and do a different output (https://codesearch.debian.net/search?q=isatty&literal=1 )

Let's say it is manageable ;-)

@europaul
Copy link
Contributor Author

Lots of tools check on that and do a different output (https://codesearch.debian.net/search?q=isatty&literal=1 )

Let's say it is manageable ;-)

I see. I had the issue that top wasn't working in the ubuntu container I used for testing. But it works in the alpine container. 🤷

@christoph-zededa
Copy link
Contributor

I see. I had the issue that top wasn't working in the ubuntu container I used for testing. But it works in the alpine container. 🤷

I guess it is busybox top vs procps-ng top.

What about editors?

@rucoder
Copy link
Contributor

rucoder commented Aug 27, 2024

@europaul I think you shoud use https://linux.die.net/man/3/posix_openpt and friends to have a pseudo terminal device and not a raw FD if you want terminal programs to work properly. I recommend reading chapter 64 "Pseudoterminals" in this book https://github.com/rangaeeeee/books-raspberrypimagazines/blob/master/The%20Linux%20Programming%20Interface-Michael%20Kerrisk.pdf

@rouming
Copy link
Contributor

rouming commented Oct 1, 2024

Recently I made an attempt to upstream working mux implementation, but in QEMU. I got some feedback, the discussion is here: https://lists.gnu.org/archive/html/qemu-devel/2024-09/msg02968.html . The patch works as is, but obviously there are some things to be addressed if we want to make this upstream. @europaul , if you wish to continue this work, please feel free to take it. Also feel free to take the patch downstream if you give up on this one PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants