Following on from recent discussion in ukc.bugs about how to get your Unix terminal back into a usable state, here is a quick summary of how the terminal driver behaves. I shall largely ignore the fact that terminals are networked at UKC, and I shall not mention any of the lovely (?) enhancements made by Berkeley to it. I will use specific examples as if they were the rule, 'cos this makes it easier to understand. The Unix terminal driver is a program fragment, like so many things, which is called into play when a process reads or writes data to a terminal character device (usually named /dev/tty*) or by interrupts from the UARTs. Characters normally undergo a certain amount of processing between the user process and the Real World, for example, on input: Carriage return (char 13) is mapped to Line feed (char 10). (Yes, you can terminate all input lines with control-J if you want) The input characters are echoed on the output so that you can see them Certain characters do not result in any input to the program, but cause strange things to happen. For example, forgets you typed the previous character, and cancels the whole input line. If echo is turned on, the terminal driver outputs appropriate characters to display the effect ("backspace space backspace" for delete) The process is given none of the input line until it is complete (before you press return). This has to be so, or delete couldn't work. control-D causes the terminal driver to indicate end-of-file to the user process, and control-C, control-Z and control-\ cause signals (interrupts, if you like) to be sent to the processes associated with that terminal. Control-S and control-Q tell the terminal driver to suspend output, and to resume it respectively. This is so that tardy terminals can shut the host up before they get swamped with data. On output, Newline is mapped to carriage-return, newline. It inserts CRLF to wrap the lines every 80 characters (or whatever) This is known as "cooked mode", and is how the terminal driver normally operates. There are two more modes, cbreak and raw. Cbreak mode differs as follows: The input characters are given to the user process as they are typed. therefore delete doesn't work unless the particular program you are running chooses to implement it. Output processing is still done (line wrapping, CRLF mapping) and the special control characters still generate signals. Raw mode drops all processing in both directions. Pressing Control-C generates a character 3, pressing return generates a character 13. To indicate end-of-line to most Unix programs in raw mode, you have to use line-feed (also known as control-J). Programs written to work in raw mode (visual editors etc) have to deal with these for themselves if they want them to have the expected effect. Echo is a bit which can be turned on and off in all modes. At UKC, most input processing in cooked mode is done in the PAD, the square brown box in the corner. The whole line is forwarded to the Unix engine when you press return. Paging is also done in the PAD; this is a UKC special, and does not happen on most Unix systems. You will miss it sorely when you leave. (Of course, one solution is not to leave 8^} ) When you're in cbreak or raw mode, the PAD forwards each character as it is typed. This is a much heavier load on the network, and on the Unix host, and is one of the impediments to teaching visual editing at UKC. To return to the original discussion, the command "reset" resets as many of the terminal modes to a sensible state as it can think of. reset is necessary because you might be in raw mode. The first control-J gets rid of any garply you might already have typed on that line, the second indicates end-of-line to the shell, and the return may be necessary because if you are already in cooked mode, the PADs don't forward the line on ^J. Other ones to watch for: If you pressed control-D and the terminal seems to have locked up - no output, no echo, no nothing - then you probably hit control-S by mistake. Press control-Q in a calm fashion, remembering that all the characters you typed while you were panicking did indeed go in, but just hadn't been echoed yet. At UKC, Control-P is also special. It enables you to give single-letter commands to the PAD, which Unix never sees. These include control-P d to drop the network connection ungracefully. This is generally a bad idea, because there are a few programs which do not exit properly when the network connection goes away, and some of them have been known to go into infinite loops. Logging out when you have "stopped jobs", without bringing them each into the foreground and getting rid of them in the usual way can cause similar problems. control-P tells you the name of the PAD line you are on, should you wish to know, because it gives you the PAD prompt control-P b sends an interrupt of some flavour - I forget which. I seem to have rambled on quite long enough. If there's something I've missed please mail me and I'll follow on. Martin