46

I do a lot of ssh-ing, and periodically I hit Ctrl+S, which naturally sends an XOFF, and causes all kinds of problems (not to mention it takes a while for me to figure out what happened, then another while to remember that I need to press Ctrl+Q to recover.

I would much rather instruct Putty to never ever let me type XOFF.

Any ideas?

5
  • 6
    +1 for pointing out that recovery is possible with Ctrl+Q. Helped me a lot!
    – Demento
    Apr 21, 2011 at 17:49
  • 3
    +1 for actually asking how to disable this behavior because it's completely antiquated and useless for my purposes. Everybody on the web has the CTRL+q trick documented, but nobody has documented how to unbind the keys altogether.
    – andrew
    Mar 11, 2012 at 8:47
  • 2
    keep in mind that ctrl+q will restore the cached flow. That means, if you press ctrl+s and then go crazy pressing ctrl+c or anything else, when you press ctrl+q all that you pressed before will be played out.
    – gcb
    Apr 17, 2013 at 19:35
  • What is the effect of an XOFF?
    – Snowcrash
    Jul 18, 2018 at 10:54
  • Comment by AFH here: you can disable Ctrl+s on Linux by adding stty stop "" to one of your start-up scripts (eg ~/.bashrc).
    – Cadoiz
    Sep 16, 2021 at 14:52

6 Answers 6

36

Don't know about Putty, but you can use:

stty -ixon

on remote host, to disable START/STOP signals.

5
  • Thanks - any idea if or how this affects the console? Would it alter the behavior of shell programs? (The only thing I know about XON/XOFF is that it's used for serial flow control). Sounds like a good setting for .bash_profile.
    – Seth
    Mar 29, 2010 at 16:57
  • That should be stty -ixon. Feb 16, 2011 at 1:44
  • Sorry. Updated my post to fix the typo.
    – Bartosz
    Feb 22, 2011 at 11:43
  • 1
    As I just commented to BlakBat on his answer, that makes ^S not send an XOFF, but it now puts me into i-search mode. Is there a way I can get bash (or PuTTY) just to discard any ^S? Even better would be if it could beep and/or flash at me ;o) Feb 14, 2012 at 15:06
  • 1
    I've added stty -ixon to my profile scripts. I've read about 100 articles on how when you press CTRL+s by accident, all you have to do is CTRL+q to resume again...but I don't want my shell to intercept CTRL+s/q at all since I use them with vim quite a bit. Thank you so much for providing an answer nobody else seems to even consider.
    – andrew
    Mar 11, 2012 at 8:46
34

The PuTTY solution:

  1. before creating the session go navigate to Connection->SSH->TTY in the list.
  2. in the "Mode" dropdown box, select IXON (nb: as of version 0.60, this list is not alphabetically ordered)
  3. put "0" (zero) as the value of IXON.

Screenshot

Works as a charm, even if you open up a "GNU screen" on top of it, SSH to another host, or "su" to another user

If you're using GNU Bash, ctrl-S should allow you now to do a forward-search-history (aka: i-search)

You can see the difference in the output of "stty -a | grep -o ".ixon": With putty configured it prints "-ixon", without " ixon"

6
  • 2
    Ok, that makes ^S not send an XOFF, but it now puts me into i-search mode. Is there a way I can get PuTTY (or bash) just to discard any ^S? Even better would be if it could beep and/or flash at me ;o) Feb 14, 2012 at 15:05
  • To deactivate an action, you can bind ^S to nothing via bind '"\C-s"'. This makes my PuTTY blink because the action is not mapped.
    – BlakBat
    Apr 23, 2012 at 10:04
  • 1
    I tired on putty 0.62 and the above setting does not help. I tried to override XON, XOFF and with different values but nothing change.
    – Dennis C
    Nov 26, 2012 at 1:42
  • 1
    This also works for nested SSH sessions using openssh as the 2nd, 3rd (etc) client Jun 1, 2015 at 4:34
  • 2
    Upvoting this answer as the best way to disable software flow control. For controlling terminal behaviour, the terminal emulator is the best place to configure it. Disabling XON/XOFF flow control in Putty means that when a pseudo-terminal is requested from a remote host, SSH servers will honour that setting when allocating the pseudo-terminal. See tools.ietf.org/html/rfc4254#section-6.2 Sep 7, 2018 at 9:33
4
.bashrc example:
#
# Stop Putty from doing XOFF/XON with Ctrl-S/Ctrl-Q
# SOURCE: http://raamdev.com/recovering-from-ctrls-in-putty (Morgy, 7/14/08)
#
# stty ixany
# stty ixoff -ixon
### If needing to listen to Ctrl-S for some apps, use these two instead:
stty stop undef
stty start undef
4

I've got the opposite problem. Every once in a while, the host sends an XOFF to PuTTY but never sends the corresponding XON to PuTTY. In this case, nothing you do to PuTTY (short of restarting it) will unwedge it. In this case, all keyboard input to the host is blocked, but the host can still send data to PuTTY.

Disabling flow control in PuTTY doesn't work.

The way to fix this problem is to use

stty -ixoff

in your .profile. This prohibits the host from sending XON/XOFF. Note that the names of the options are totally confusing. ixon/-ixon means enable/disable flow control on the client side (meaning that the client can't issue flow control), ixoff/-ixoff means enable/disable flow control on the host side (meaning the host can't issue flow control).

Btw, the ASCII code for Ctrl-S and XOFF are the same ASCII character (code 19, 0x13). There's no difference. The settings change the interpretation of that ASCII character.

3
  • Oh man, I've searched everywhere for an explanation for ixon and ixoff. Sending XON/XOFF from client to host makes sense. However, I'm still confused, in what situations does the host send to the client flow control XON/XOFF? I see "when the input queue is nearly empty/full"? Does this happen with modern computers, as in not connecting to slow printers? But what does that practically mean? What happens to the terminal UI? Apr 28, 2016 at 16:23
  • Flow control works in both directions. A modern computer is always doing a million other things, and it can "lock up" doing critical activity. During this time, it can't service the serial port and the serial port will overflow unless the terminal shuts up. So the host sends XOFF to the terminal requesting it to stop sending. Once the pressure is off, the host sends XON. (btw, computer serial ports usually only have a small hardware buffer, say 16 bytes.) Even though this is ancient technology, anything that is not designed for real-time will occasionally "hang" so flow control is needed. Apr 28, 2016 at 17:37
  • 1
    BTW, I have found cases where a tiny little 20 MHz microcontroller is able to overflow a 3 GHz host computer, but not vice versa. That is because the microcontroller is only doing one thing and designed with real-time in mind, while the host computer is not. Apr 28, 2016 at 17:39
3

Open your .bash_profile and put:

stty -ixon

The value -xion doen't work for me. You can see the man entry: man stty.

1
  • +1 for stty -xion does not work on my centos, but stty -ixon works.
    – Jichao
    Dec 9, 2010 at 16:18
-1

Run this command in terminal to disable it for current session/add it to .bashrc for disabling it permanently

stty -ixon

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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