[clug] Programmable title [a riff on Days of Yore]

steve jenkin sjenkin at canb.auug.org.au
Fri Oct 17 18:04:47 MDT 2014

On 18 Oct 2014, at 12:05 am, Bryan Kilgallin <bryan at netspeed.com.au> wrote:

> Thanks guys. The following seems to do what I wanted. Though I don't know how to force the terminal to be of type "tty" as opposed to "pts", in order to test that condition.


The ‘tty’ command, and ‘ps’, display the terminal device you’re on (use stty is “set tty values”) - they’re allocated at login, you don’t get to choose a name/type.

Because you’re not on a directly connected serial device, you get a “pseudo-tty", the slave side of which is /dev/pts…IIRC, /dev/ptm… is the master side.

Every Unix/POSIX system names their pseudo-tty’s differently. try ‘man pty’ and "man -s 4 tty” (man in section 4 for tty, sometime “man 4 tty”)).
Use "ls -l /dev/pt[sm]*" to explore the device major/minor numbers allocated. (& try “ls -l /dev/tty”, next)

Every process attached to a terminal (daemons don’t have one, you can test for a controlling tty with the shell) has "/dev/tty” that always points to the controlling terminal. This abstraction, a constant name, came after all the kernel structures, device drivers and commands were well established.
You can use "/dev/tty" in a shell script, or program, to interact with the user without going via stdin, stdout, stderr (file descriptors 0, 1, 2).
I have limited knowledge/experience of this.

Perhaps someone can write something on how tty’s are seen in the modern "/proc” pseudo-filesystem.

I googled for “unix tty history”.

The link below was the first search result, it’s actually pretty complete and comes with what seem to be reasonable diagrams.
 It should help explain to you what’s going on. It’s not how you’d design something from scratch these days, there’s a lot of ‘cruft’ in there added since 1969 as new technologies arrived. The number of “termio()” parameters [set by ioctl()] is astounding, as are terminal control strings and all the X-11 'stuff'. Luckily you seldom need to know or use at any of this.

Flow control (^S, ^Q) and “sessions” & job control (^Z) are _really_ useful, even with modern Display Manager/GUI systems. Simple to learn and can be a life saver, especially at a console.
He mentions both 'screen’ and ‘ssh’, where you often have just a single terminal session - they create & manage the pairs (master/slave) of pseudo terminal devices they need.
Process Groups and session leaders are mentioned too - these were very important concepts when developed.

“stty sane” [with a ctrl-J not ‘return’] is something necessary to reset your terminal if it stops echoing or starts printing weird characters.


Hope that’s Helpful.


Steve Jenkin, IT Systems and Design 
0412 786 915 (+61 412 786 915)
PO Box 48, Kippax ACT 2615, AUSTRALIA

mailto:sjenkin at canb.auug.org.au http://members.tip.net.au/~sjenkin

More information about the linux mailing list