Wednesday, April 1, 2009
Ctrl-s in Linux shell - vi hangs
It happened to me a lot many times. While working on Linux terminal, sometime my terminal hangs due to some key strokes that I make in hurry. Was not sure which key combination did the terminal to freeze. At last I found that. Thought of sharing here.
Pressing Ctrl-s inside vi editor or in Linux shell freezes the shell as it locks the terminal output.
We need to press Ctrl-q to resume the terminal output.
Subscribe to:
Post Comments (Atom)
© Jadu Saikia www.UNIXCL.com
14 comments:
The first time it happened to me I used: killall vim, until I know that ctrl+q unfreeze the terminal.
However ctrl+s is a a useful feature. Right now I use gvim more than vim.
Ctrl-S and Ctrl-Q have been around since the days of green-screens and dumb terminals (aka the 80s). Ctrl-S is scroll-lock on, and Ctrl-Q is scroll lock off. This works in a lot of places on a lot of operating systems. Try it when booting or shutting down at a text screen. Chances are Ctrl-S will stop the scrolling messages. When done, press Ctrl-Q to continue.
Ctrl-s and Ctrl-q are standard handshake protocols also refered to XOFF and XON. These are software handshake characters and there are also hardware handshake protocols using CTR/RTS lines. These protocols were used for modems and printers which were slower than the computer and date back over 20 years. See the attached link.
http://whatis.techtarget.com/definition/0,,sid9_gci213406,00.html
sounds like you are using the konsole terminal from kde4 series.
yes, ctrl-s suspends konsole and ctrl-q resumes processing.
It doesn't freeze the output... Ctrl S is the Xoff character, uses for flow control on serial links that do not have hardware flow control.
Receipt of the XON character (Ctrl Q) disables the flow control, and commands output to continue.
This has been the standard almost since the beginning of time. The trouble is that people have forgotten history.
This mechanism is provided to allow flow control. Fortunately, since you can enter those characters from the keyboard, it also allow a human to control the flow also. See 'man stty' for more information about all the features that are available.
Thanks!
This is the best tip I got since a while.
It never occured to me that there was a fix. I always ended up closing the session by force and killingall vim.
Thanks again,
- Kefah.
Hahahaha, this one got me for aaaages until I discovered what was going wrong.
right! It is helpful.Thanks
Thanks !! this really helps
Thanks !! This really helped
Thanks a lot Jadu Saikia. You saved a lot of head scratching :)
accidentally thought I was in emacs and this happened to me. Thanks for this!
Thank you! I keep hitting ctrl s due to muscle memory from working on windows and had to resort to killing vim.
I know this is an older post but still very relevant, I accidentally hit ctrl-s every other day and would wind up killing the terminal while thinking it was either urxvt or bash/vim that froze on me.. I thank you very much for this explanation!
Post a Comment