Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

CTRL+s stops all output to the terminal which can be restarted with CTRL+q.

But, why does CTRL+s exist in the first place? What problem was trying to be solved by putting that control sequence in place?

share|improve this question
4  
See : linusakesson.net/programming/tty (read it all, but especially the section about Flow Control...) –  Olivier Dulac Jun 19 at 11:18
7  
Have used Ctrl-S/Ctrl-Q to save my bacon many times to stop runaway output of error messages on a barely functional system so I could see what they were. –  DocSalvage Jun 20 at 8:12
    
As a side note, I have this in my .bashrc to disable both functions: stty stop ''; stty start '';. This leaves Ctrl-S free for use as the escape character for screen, with this in my .screenrc: escape ^Ss. Which in turn means that I can use the standard readline shortcut Ctrl-A for "beginning of line" (matched with Ctrl-E for "end of line", and less fragile to terminal emulation than Home and End). :D –  IMSoP Jun 22 at 22:47
add comment

4 Answers 4

up vote 80 down vote accepted

Long before there were computers, there were teleprinters (aka teletypewriters, aka teletypes). Think of them as roughly the same technology as a telegraph, but with some type of keyboard and some type of printer attached to them.

Because teletypes already existed when computers were first being built, and because computers at the time were room-sized, teletypes became a convenient user interface to the first computers - type in a command, hit the send button, wait for a while, and the output of the command is printed to a sheet of paper in front of you.

Software flow control originated around this era - if the printer couldn't print as fast as the teletype was receiving data, for instance, the teletype could send an XOFF flow control command (Ctrl-S) to the remote side saying "Stop transmitting for now", and then could send the XON flow control command (Ctrl-Q) to the remote side saying "I've caught up, please continue".

And this usage survives on in Unix because modern terminal emulators are emulating physical terminals (like the vt100) which themselves were (in some ways) emulating teletypes.

share|improve this answer
15  
Most likely not "printed to a sheet of paper" but "printed to a stack of fanfold paper". –  Dubu Jun 18 at 15:08
3  
Or to a ROLL of punched tape! –  mdpc Jun 18 at 17:36
2  
I don't think control-S and control-Q were initially used to start and stop output from computers, but rather from paper-tape readers attached to other teletypes. I don't think there would have been much interest in connecting teletypes to computers until the advent of time-sharing systems. Otherwise any time a computer spends waiting for a user to type something is time it isn't spending doing something useful. –  supercat Jun 18 at 23:24
2  
Or to a roll of 8½ʹʹ paper. –  Scott Jun 19 at 16:25
6  
Back in 1987 I made the last teletype that had survived in my university go up in flames. Used it as a serial printer and didn't realize it would overheat if forced to print 35 pages continuously. The overheating just smelled bad, but then the paper caught fire because of the heat. Only then did they tell me I should have given a Ctrl-S every 2 pages or so to let it cool down for a couple of minutes. –  Tonny Jun 20 at 21:36
show 1 more comment

It's a control character from the time of the VT100 terminals and similar. There was limited scrolling capability (if any) on those terminals to begin with the CTRL-S allowed you to freeze output to view what is currently on the screen without it being written off.

Most everything that you see in modern terminals was put in place to emulate those older terminal systems.

share|improve this answer
    
This is what I have heard, (rather than the teleprinter answer, though it is possible (probably even) that this is the reason such functionality was preserved.) I have used Cntr-S for this purpose, when having issues with more or less –  Oxinabox Jun 20 at 9:58
1  
The mechanical need to start/stop output came before the human need to be able to read it! –  TripeHound Jun 20 at 12:14
    
@TripeHound: Indeed, it came long before there was any particular expectation that humans would be looking at the information while it was received (someone who was eagerly awaiting a story might watch as it was received by a teletype, but operators usually had better things to do). –  supercat Jun 20 at 16:56
add comment

BTW, if you are listing a long output on your screen, chances are that you do not necessarily read as fast as the computer that spits out the output. Using CTRL-S/CTRL-Q on a cat (or active tail) is VERY useful to stop and resume output.

share|improve this answer
12  
less is more. –  dotancohen Jun 19 at 5:46
2  
@dotancohen: Very funny. Even more wasn't introduced until four or five years after the first Unix (featuring cat, but not cat -v) was released. Note also that there were other timesharing (interactive) operating systems before Unix; e.g., RSTS. –  Scott Jun 19 at 16:17
    
@dotancohen I prefer less, but people say that, while less is more, most is still more than less! –  Volker Siegel Jun 20 at 1:49
    
@VolkerSiegel: Thank you for introducing me to most! On the off chance that you know of a program that lets one see an image file (gif, jpg, png) over ssh on the cli, I'd love to hear about it. I currently use asciiview or img2txt but neither are satisfactory. –  dotancohen Jun 20 at 15:46
    
@VolkerSiegel: Also thanks for most! As the author says: "Why settle for less?". Debian users can apt-get install most. –  mivk Jun 22 at 12:58
add comment

On ancient teletypes with a paper tape reader, receipt of a control-Q would turn on the paper tape reader and start sending out characters from the tape as though they had been typed at the keyboard. Control-S would turn off the paper tape reader. If one considers that teletypes were originally intended not to print data from computers, but rather from other teletypes, it should be pretty clear how "turn off paper tape reader" could be construed as analogous to "request other end to stop transmitting".

Incidentally, control-R would turn on the paper-tape punch, such that every character received by the teletype (or, if local echo was enabled, typed at the keyboard) would also get punched to the paper tape; control-T would turn off the paper-tape punch. Unlike the operations associated with control-S and control-Q, however, those operations seem to have no modern equivalent.

Also, the original names for control-Q/R/S/T were DC1/DC2/DC3/DC4 ("Device Control 1", etc.) While I'm not certain of the history, such naming would suggest that originally they were intended to trigger some unspecified kind of action, but the most common thing people did with DC1 and DC3 was to control the paper tape reader.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.