7 ms·
The TTY Demystified
- pooriaazimi 14y agoVery informative article. What I love is how they come up with different names for different signals that kill/suspend processes: `SIGHUP`, `SIGINT`, `SIGQUIT`, `SIGABRT`, `SIGKILL`, `SIGTERM` and `SIGSTOP`! 7 different combinations of SIG and a verb that means "terminate/kill/stop/close/quit/suspend", and it's not that confusing (once you get your head around it). Must have been quite a challenge!
- emmelaich 14y agoAlthough sigkill should've been named sigstop and sigstop should've been sigpause. Ah, hindsight is a wonderful thing.
- jlgreco 14y agoEh, do you stop your car at an intersection, or do you pause it?
- snogglethorpe 14y agoThe names are not entirely arbitrary, though, and the nuances are actually meaningful, and based on real-world behavior. E.g., "HUP" means hangup, and indeed, that's what you get when your modem hangs up accidentally! When handled by an application, it often is treated appropriately (e.g., the handler might trigger an autosave before quitting). "INT" means "interrupt", and usage follows that sense -- it more likely than others to be ignored/repurposed (e.g. to quit back to some application prompt rather than killing the application entirely). "ABRT" means "abort", and is typically used as a last-ditch means of killing the program when an internal error is detected. "KILL" is more draconian than any other; there is no recovery possible. etc.
- ChuckMcM 14y agoThis is a great article, at some point it will be a story like how the rail spacing in England is a function of the ruts created by the Roman chariots (unclear if that is actually the case (see snopes etc)), Having written tty driver code for FiNE (Fine-is-not-EMACS) there was a lot stuff related to just how fast the terminal on the other end of the serial channel could do stuff. (we had tunables for insert line, scroll etc).
- jrabone 14y agoGreat article, and your point about tunables is spot on; in the guts of several curses implementations there's an evil little select() call which is trying to work out if you meant "cursor down 1 line" or the four seperate characters ESC, [, 1, A by doing millisecond-precise timings. IMHO I think this all needs to be replaced with something sane. VT100 is obsolete, and we can now spare a few more BPS for a better terminal layer. Wasn't so long ago that if you left capslock on, something (getty?) on the Linux console would assume your terminal was one of those olde-worlde 6-bit ones, and stop using lowercase letters...
- dllthomas 14y ago> IMHO I think this all needs to be replaced with something sane. It seems that we're in the process of replacing it with web tech, which may or may not meet your definition of "something sane"...
- cturner 14y agoWeb isn't a replacement. It doesn't and won't ever have consistent keyboard handling across platforms and browser upgrades. As a result, it has evolved to being mouse-centric, and is inadequate for high-volume users. There are many web systems being developed as business front-ends today that would suck less were they menu and form-driven terminal apps with a couple of web screens for reports. (or a websockets arrangement where the terminal could render certain things to an associated browser when appropriate)
- Jamiecon 14y agoWhere I work, our > 15 year old ticket retail system was developed on a platform called Dataflex [0], which provides a character mode user interface. We have since migrated the datastore from the embedded ISAM database to Postgres, and built eCommerce and other web applications around the original schema. Our administrative and call centre staff continue to use the original character mode interface to interact with the data and do their daily work. The software works and we have no reason to redevelop it anyway, but seriously, you should see the speed with which experienced staff move around the system. Editors can input hundreds of events an hour and call centre staff are amazingly efficient - they can practically use the thing blindfold. There's a lot to be said for consistent keyboard controls and a distraction free interface in the workplace. Line of business applications from the last couple of decades, mostly mouse driven, are often tragically inefficient. [0] http://en.wikipedia.org/wiki/Dataflex http://en.wikipedia.org/wiki/Dataflex
- cientifico 14y agoHow many times this article appear at the hacker new front page?
- johncoltrane 14y agoDidn't spot it the previous times.
- tisme 14y agohttp://news.ycombinator.com/item?id=658155 http://news.ycombinator.com/item?id=658155 http://news.ycombinator.com/item?id=4062981 http://news.ycombinator.com/item?id=4062981
- noirman 14y agoPreviously on Hacker News: http://news.ycombinator.com/item?id=4062981 http://news.ycombinator.com/item?id=4062981
- joedoe55555 14y agoOk, so how do I build a teletype that I can connect via USB to my Mac? (And will vi work? :D)
- johncoltrane 14y agoWhile not exactly a teletype, Justin Ouelette's VT220 is cool: http://jstn.cc/post/8692501831 http://jstn.cc/post/8692501831 http://jstn.cc/post/13476503553 http://jstn.cc/post/13476503553 http://jstn.cc/post/10831555077 http://jstn.cc/post/10831555077 http://www.fastcodesign.com/1665509/digital-archaeology-hacker-gets-2011-mac-os-to-run-on-1983-computer http://www.fastcodesign.com/1665509/digital-archaeology-hack... http://justinouellette.com/ http://justinouellette.com/
- jff 14y agoWhat's most amazing to me is that this got so much press. Maybe OS X is ridiculously hard to set up, but I've been doing this on and off with my own VT 220 for the last 5 years on Linux. It's just... not that big of a deal. It's not archaeology, it's just pointing getty at /dev/ttyS0. I've done it with an ADM-3A from the 70s too, it's just. Not. That. Tough. http://imgur.com/bRnST http://imgur.com/bRnST here's me, years back, hacking on a VT 220
- derleth 14y agoOn the hardware level, does the VT 220 connect via a standard nine-pin serial port?
- jff 14y agoIt has a 25-pin serial port which converts to a 9-pin serial port by a simple passive converter (basically, just ditch 16 of the pins and route the others properly, you can actually do serial with just two wires). Same goes for the ADM-3a
- jasomill 14y agoIIRC, while the VT-220 had both 9-pin and 25-pin RS-232 ports, the 9-pin port was used to attach a printer. You also typically need a "null modem" adapter or cable to connect a terminal directly to a PC serial port (or USB serial adapter). There's lots of original documentation for DEC VT series terminals here[1]. [1] http://www.vt100.net/ http://www.vt100.net/
- Zenst 14y agoNice read, the part at the end "Finally, stty sane will restore your TTY device configuration to something reasonable" Realy should be what you learn from your fist instance of using a terminal (to many bad memorys of yesteryear systems over RS232 and uucp and modems, stop me now). But everybody learns what they need to learn, even if it is setting the backspace/del keys to something visualy complient. Knowing a tty and VT commands you can do some realy simple clever stuff, like find certain people logged in and there tty and cat append information to there screens and if they have terminals with extra sub lines you can sends a string that will memorise the screen cursor position, reposition cursor to the lower lines and display your text and then restore the cursor position. A very easy and simple way to instantly alert logged on users in certain groups. Can do all that in shell script easily. So knowing how things work and there capabilities and even there history and background so you understand why they are the way they are and from that appreciete there limitations. Then you can start doing some realy fun things. Again, nice read as verifys what you know and will fill in some worthy blanks.
- kps 14y agoOften when TTY settings are messed up by a full-screen program, you need to type «Control-J stty sane Control-J». It's necessary to use Control-J (i.e. newline) explicitly instead of pressing Return or Enter, because those generally send CR (Carriage Return, Control-M) and CR-to-newline translation is off.
- Zenst 14y agoVery true I instinctly do a ctrl-c first, but once you learn to not cat binary's/unsanatised data to your terminal you learn to add strings or use OD instead.
- sharkweek 14y agoFascinating read -- when I was a bit... less mature, I used to use this service for many a prank call, which at one point apparently accounted for 85-90% of the calls according to some operators: http://en.wikipedia.org/wiki/Telecommunications_relay_service#Fraudulent_uses_in_the_United_States http://en.wikipedia.org/wiki/Telecommunications_relay_servic...
- stox 14y agoThe concept of a teletype predated ASCII by decades. I would not use this article for any historical references.
- cm3 14y agoThis shows why Plan 9 as part of the plan to fix inconsistencies and problems in UNIX wrote a terminal which doesn't even support escape sequences for coloring. I'm not a Plan 9 expert but it's actually for the better. Try launching some program like the sudoku game or acme from 9term inside Plan 9 compared to doing the same in plan9port's 9term or a plain xterm. On Plan 9 your 9term will become the program you launch.
- zx2c4 14y agoThe article makes an interesting point "There's an important difference here: Writing to a TTY which is stopped due to flow control, or due to lack of kernel buffer space, will block your process, whereas writing to a TTY from a background job will cause a SIGTTOU to suspend the entire process group. I don't know why the designers of UNIX had to go all the way to invent SIGTTOU and SIGTTIN instead of relying on blocking I/O, but my best guess is that the TTY driver, being in charge of job control, was designed to monitor and manipulate whole jobs; never the individual processes within them." Can anyone provide any more insight about this?