There’s an odd kind of arrogance to me—I often behave as though I think I can explain things much better than other people. Sometimes I am accorded the rare opportunity of being one of the first to explain something, such as Kasai’s algorithm. Other times, I explain things that have already been explained many times. I wrote an explanation for Manacher’s algorithm, and probably a poor one, at that. I have an unfinished exposition of the Size-Balanced Tree data structure, because I think I can explain it better than the author. (To be fair, he is from China and his English is not perfect). I even thought about writing a tutorial about Haskell monads at some point—which I ended up not doing, because it turns out that I am not quite arrogant enough to believe that I actually understand Haskell monads. I even—get this—have a grand plan to write a linked series of textbooks that will cover everything I know about undergraduate mathematics and physics, in a fashion more interrelated than what anyone else could offer, since nobody has ever done this before. (Frickin’ Brian. Who does he think he is, the next Lev Landau?!)
Anyway, recently I got it into my head that I should write about terminal devices in Linux. (I say Linux, but most of what I will write will apply just as well to other Unix-like systems.) It always seems that people are terminally confused (excuse the lame joke), and that even very smart people have quite a hard time understanding them. Furthermore, should you have a question about terminals, such as: how does the master end of a pty learn that the slave end has been ioctl
(2)ed, it’s quite hard to find the answer by searching online. There doesn’t seem to be one place where you can read as much about terminals as you care to, unless you can read the Linux source code.
I’ve answered two questions about terminals on Quora recently: [1] and [2], and in each case I felt that I couldn’t tell the whole story because it would make my answer too long, even though I wanted to. Also, I learned a lot about terminals myself in the process, and I expect to learn even more if I explain terminals as fully as I can. So that’s what I intend to do now.
This tutorial will be broken up into an undetermined number of parts. This post is part zero, the introduction, as it doesn’t contain any actual information about terminals. I have to sleep now, since I have things to do tomorrow. But I hope to soon return and write part one.