I'm trying to understand how the programs like
script control I/O.
My knowledge of terminal, tty etc. comes from reading the 'tty demystified' article, and all the SE answers I could find. So from what I understand, roughly the interactions between components work as follows:
Console(Keyboard+Screen) ---- xterm(pty master) ----- tty line discipline ---- bash/other programs(pty slave)
where the line discipline is in the kernel, and xterm and bash run in the userspace.
- Is this correct?
Now, when we consider programs like
script, they are userspace programs that run in a terminal(the existing xterm), yet are able to control I/O to/from other programs. The article mentions that this is becuase they run another pseudoterminal inside xterm(the existing pseudoterminal).
Does that mean that they open up a new
ptymaster - slave pair, control the master end of this new pair, and all the processes launched from them run on the new
ptyslave? For example each time I start a new 'screen', and run the
ttycommand, it shows me a diffrent
scriptalso run in a similar way?
Finally can somebody point me to any article/book where I can get a little more detail on this stuff(Haven't been able to find anything)?
I'd also like to reference this answer, though it is very brief.