Why does Ctrl+\ (backslash) not kill the process any more?

For a while, Ctrl+\ worked like a charm. Now, it does not kill the process. In fact it does nothing.

An example how it does NOT work:

adi@ebi:~ $ sleep 10
^C

[exited with 130]
adi@ebi:~ $ sleep 10
^\^\^\^\^\^\^\^\^\^\^\ 
adi@ebi:~ $

Ctrl+C stops sleep as usual, but Ctrl+\ does not, but it should, right?


Solution 1:

What Ctrl + \ does is send SIGQUIT to the foreground process. Some developers want to use SIG* events in a way that the user might not expect or is accustomed to. You didn't mention the program, but lets see my case with Ctrl + \ and mplayer:

AO: [pulse] 44100Hz 2ch floatle (4 bytes per sample)
Video: no video
Starting playback...
A:   1.7 (01.7) of 0.0 (unknown)  0.4% 
// here I press Ctrl + \

MPlayer interrupted by signal 3 in module: play_audio
A:   1.0 (00.9) of 0.0 (unknown)  0.4% 

Exiting... (Quit)

As you see, mplayer catch the signal, but don't exit immediately. If I had used Ctrl + C it would say "MPlayer interrupted by signal 2 in module: play_audio". What I'm trying to explain is that each program can interpret the signals the way they like, without caring for what it is supposed to do. You must review the documentation. Also, remember that SIGKILL or 9 should be resorted as last resource. You must check that the keystrokes are also sent to the process, the keymap is correct and your keyboard is connected.

Solution 2:

You can list your terminal settings by executing

stty -a

It will print out your hotkeys, where "^" stands fro Ctrl, e.g mine is:

intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O;

Check man stty to see which special character does what e.g:

quit CHAR
          CHAR will send a quit signal

So "quit = ^\" in my output means that if I press Ctrl+\ it will send a quit signal (SIGQUIT) to the process. If your stty -a output is different, then you can set it with

stty quit ^\

or if you want e.g. Ctrl+K for the SIGQUIT signal use

stty quit ^k

But note that every signal except the SIGKILL can be caught by the receiving process so the process can ignore it if it's developer decided to do so. And also I think that using Ctrl+C (SIGINT) is better then using Ctrl+\ (SIGQUIT), because the default action for both signal is to end the process but in case of SIGQUIT a coredump should also be made, which I think is usually not wanted.