If I have a pty or tty master/slave pair, what can I not do with it if I only have the slave node's file descriptor? Or, put another way: what can I only do if I have the master node's file descriptor?
I grok the "typical" relationship of a terminal/console/SSH having the master end for interfacing with a human, and one or more program (e.g. a shell and its children processes) being on the slave end. And I (loosely) grok the more unusual(/archaic?) usecases like using a TTY for other kinds of data links, like PPP. This question is not a "I don't get this TTY business" question. I'm asking about the ("low-level"?) "API" stuff: e.g. is there any termios/ioctl manipulations or other programmatic changes to the TTY pair that cannot be accomplished if you don't have access to the master FD?
I guess the obvious ones are:
Anything else?
I've been on/off reading some man pages and experimenting on my Linux machines: the basic stuff one would want to do with a pty (e.g. stty columns 78
, etc) seems to work on "either end". But I would suspect there's stuff only a process holding a file descriptor of the master end can do (especially because the master-slave name dichotomy suggests some unilateral control/dominion). And of course since I'm only testing on Linux, there's possible behavior differences between various versions/configurations of Linux and vs. the Unixes, so I don't want to assume that what I'm seeing is portable.
(In case someone wants to know why I want to know)
reptyr
, ptyget
, expect
/empty
, screen
/tmux
(/neercs
? the one with reptyr
-like feature), dtach
/abduco
, and none of them hit my sweetspot of minimalist versatility. I'm trying to become more informed so I can better evaluate existing solutions and/or better design my own tool(s) to scratch my particular itch.Software terminal, i.e., virtual TeleTYpe (TTY), which is the main interface of a Linux operating system. Software pseudo-terminal, i.e., PseudoTeletYpe (PTY), which allows emulating a TTY. Software terminal emulator, based on the previous ideas, but usually enhancing them via the actual or CLI-emulated GUI.
Source code: Lib/pty.py. The pty module defines operations for handling the pseudo-terminal concept: starting another process and being able to write to and read from its controlling terminal programmatically. Pseudo-terminal handling is highly platform dependent.
Thanks to StackOverflow's related-questions suggestions and other online searching since asking this, I've found a (partial?) answer:
I'll try to keep coming back to edit this as I learn more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With