Can you disable the Ctrl-S (XOFF) keystroke in Putty?

42

17

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?

Seth

Posted 2010-03-27T20:55:52.077

Reputation: 997

What is the effect of an XOFF? – Snowcrash – 2018-07-18T10:54:47.427

6+1 for pointing out that recovery is possible with Ctrl+Q. Helped me a lot! – Demento – 2011-04-21T17:49:18.677

1+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 – 2012-03-11T08:47:28.343

1keep 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 – 2013-04-17T19:35:07.240

Answers

35

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

stty -ixon

on remote host, to disable START/STOP signals.

Bartosz

Posted 2010-03-27T20:55:52.077

Reputation: 466

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 – 2010-03-29T16:57:54.370

That should be stty -ixon. – Oddthinking – 2011-02-16T01:44:30.570

Sorry. Updated my post to fix the typo. – Bartosz – 2011-02-22T11:43:31.613

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)

– Owen Blacker – 2012-02-14T15:06:35.313

1I'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 – 2012-03-11T08:46:02.353

30

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"

BlakBat

Posted 2010-03-27T20:55:52.077

Reputation: 1 038

1This also works for nested SSH sessions using openssh as the 2nd, 3rd (etc) client – Felipe Alvarez – 2015-06-01T04:34:00.060

1

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 https://tools.ietf.org/html/rfc4254#section-6.2

– Anthony Geoghegan – 2018-09-07T09:33:47.613

2Ok, 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) – Owen Blacker – 2012-02-14T15:05:08.247

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 – 2012-04-23T10:04:48.040

1I 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 – 2012-11-26T01:42:58.637

same as @DennisCheung. btw this is the worst setting screen i've ever saw. what does those values even mean? auto? zero? anyway, removed the original IXOFF and added IXOFF=0, ctrl+s still does it's thing – gcb – 2013-04-17T19:41:26.923

5

.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

Jack Hamilton

Posted 2010-03-27T20:55:52.077

Reputation: 51

5

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.

Mark Lakata

Posted 2010-03-27T20:55:52.077

Reputation: 4 260

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? – CMCDragonkai – 2016-04-28T16:23:49.987

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. – Mark Lakata – 2016-04-28T17:37:56.383

1BTW, 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. – Mark Lakata – 2016-04-28T17:39:07.343

4

Open your .bash_profile and put:

stty -ixon

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

Fids

Posted 2010-03-27T20:55:52.077

Reputation: 41

+1 for stty -xion does not work on my centos, but stty -ixon works. – Jichao – 2010-12-09T16:18:32.107

0

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

stty -ixon

Aldrin Bennet

Posted 2010-03-27T20:55:52.077

Reputation: 1