Twitter Updates

Wednesday, 9 July 2008

Screen CTRL-S Bug

When switching between terminals and text editors the occasional ctrl-s gets accidentally typed into the terminal. For along time I thought that this was a bug in screen but it is a standard terminal feature. Ctrl-s calls the software flow control method XOFF which stops the character flow to the terminal, which when you did not realise what you pressed just seems to freeze the terminal.

ctrl-q calls XON and starts the terminal again.

For a more permanent fix you can add this to your .bashrc (not sure how other shells are effected).

stty ixany

Which allows any character to call XON, so the character press is sent and displayed and you will never be aware of the terminal freezing.

If this does not work for you, or you also don't seem to be able to send ctrl-s ctrl-q commands to terminal applications you can use
stty stop undef To unmap ctrl-s
stty start undef To unmap ctrl-q

Or to stop XOFF and XON being sent from the keyboard but still allowing other software to send the commands use
stty ixoff -ixon
NB: ctrl-q can now be used to shutdown rtorrent

9 comments:

Anonymous said...

stty ixoff -ixon worked great!

Was annoying not being able to resume torrents on rtorrent when running within screen

Thanks!

Anonymous said...

you can also set it permanently with ttyModes adding this line

xterm*ttyModes stop ^-

to .Xresources

Anonymous said...

"Each window has an initial flow-control value set with either the `-f' option or the defflow command. By default the windows are set to automatic flow-switching. It can then be toggled between the three states 'fixed on', 'fixed off' and 'automatic' interactively with the flow command bound to C-a f."
So basically, you should make sure your flow setting is correct for your usage.
For example: "-flow" works great with rtorrent.

Morgy said...

The screen defflow command and switching between flow modes is also described here :
http://web.mit.edu/gnu/doc/html/screen_14.html

Anonymous said...

Thank you so much :-) This was of great help.

Anonymous said...

NOTE: To avoid tty problems with SSH (i.e. errors like "stty: stdin isn't a terminal), you can enclose "stty ixany" in an if statement to only run that command if stdin is a terminal.

if [ -t 0 ]; then
stty ixany
fi

Anonymous said...

Thank you VER VERY VERY VERY VERY VERY VERY VERY VERY VERY MUTCH, you saved me on this day

Frederico Liporace said...

Thanks, solved my problem.

Surya said...

I am exactly in the same stage where you were thinking it as a bug...:)

Thank you so much.. Good knowledge sharing..