Linux – How to disable ^C from being echoed on Linux on Ctrl-C

kernellinuxsignalterminal

When I press Ctrl-C in any pseudoterminal (xterm, gnome-terminal, rxvt, text console and SSH) in Karmic Koala, the string ^C gets echoed to the terminal in Ubuntu Karmic Koala. This hasn't happened in Ubuntu Jaunty Jackalope. I'd like to get rid of the extra ^C. Example:

$ cat
foo
foo
^C
$ _

I got the above by typing C, A, T, Enter, F, O, O, Enter, Ctrl-C. I want to get rid of the ^C, and get this for the same keypresses:

$ cat
foo
foo

$ _

I tried setting stty -echoctl, which solved the problem for rxvt and xterm outside SSH, but it created a single-character HT when SSHing from an Ubuntu Hardy system, and it created a box with Unicode 0003 in it instead of the ^C in gnome-terminal. I want to see absolutely nothing when I press Ctrl-C. I'm using

Linux linux 2.6.31-20-generic-pae #57-Ubuntu SMP Mon Feb 8 10:23:59 UTC 2010 i686 GNU/Linux

I have these terminal settings in all systems and all terminal emulators:

ioctl(0, TCGETS, {c_iflags=0x2502, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"})

Best Answer

Do this and record the results:

stty -a

Then try:

stty sane
stty -echoctl

Then if Ctrl-C works the way you expect:

stty -a

and compare the results to the ones you recorded above.

Edit:

This has been filed as a bug against gnome-terminal. You can produce similar behavior with printf '\003\n'. PuTTY and xterm display a blank line, but gnome-terminal displays a Unicode box.