Using Pseudo-Terminals to Control Interactive Programs (2010)
rachid.koucha.free.fr
rachid.koucha.free.fr
One of Tcl's first "killer apps". Don Libes' (creator of Expect) book "Exploring Expect" is also one of those technical masterpieces that are very enjoyable, entertaining technical reads. Recommended if only for the discussions of terminals and interactive i/o.
[edit: typo/punctuation]
This is of particular concern to container runtimes, so I recently wrote a patch that added a new tty_ioctl(4)[1] to make things _slightly_ better (though I think the pty namespacing concept really needs to be reworked -- not to mention the countless lovely problems with Linux's namespace primitives). Effectively it allows you to safely open a slavefd given a masterfd (without needing to worry about mount namespace issues).
Short story, if you're an author of a container runtime I would take a look at using that feature.
[1]: https://marc.info/?l=linux-kernel&m=149649933504954&w=2