Why does CTRL+S freeze your PuTTY screen?

Jacob Allred

tl;dr - If you hit CTRL+S in PuTTY, your screen will freeze. Anything you type will still be sent to the server. Press CTRL+Q to unfreeze your screen.

Imagine you are an old laser printer. You have something like 128 KB of memory. You print a max of 8 pages per minute. Someone decides to print the man page for gcc.

You are doing the best you can, cranking out pages and pages of obscure options and arguments. Your 128 KB of memory is quickly filling up. What do you do? You use flow control to send an XOFF to the computer. This message tells the computer that, for whatever reason, you need it to stop sending data. You print a few pages, you free up some memory, so you send XON to the computer. This message tells the computer that you are ready for it to start sending data again. This cycle repeats itself until you’ve received the full document from the computer.

These XOFF and XON controls are built-in to PuTTY, too. And they can be super useful. Imagine you are tailing a log file, and you catch a glimpse of an error message. Hit CTRL+S to send XOFF and the screen will freeze for you. When you are done, hit CTRL+Q to send XON and the screen will unfreeze. Yay!

It is important to keep in mind that XOFF only stops transmissions coming FROM the server. If you hit CTRL+S and start bashing the keyboard, all those keystrokes are going to make it to the server.

Another caveat is that you’ll lose any screen updates between hitting CTRL+S and CTRL+Q. This isn’t a DVR. You can’t go forward and backward. Hitting CTRL+Q goes back to “live TV” so to speak.

If you don’t care for this feature, you can easily disable it. Simply add the following to ~/.bashrc:

stty ixany stty ixoff -ixon

The first line will let any character restart output, just in case the server receives an XOFF somehow. The second line enables the sending of start and stop characters, but disables XON/XOFF flow control. Realistically stty -ixon should be good enough, but the other bits provide some extra safety against unexpected screen freezes.