Ctrl+C does not quit a running program in terminal
Ok, I don't know why, but I've seen this question been asked many times, but none of the answers seem to be helpful, yet the problem is quite obvious, because I verified it on several computers. Ctrl+C does NOT kill a running program in terminal (Ubuntu v10) even though it's supposed to. I wonder if anyone can actually point a solution that actually works.
So far I've tried Ctrl+\, Ctrl+SysRq+K, and much more - nothing works!
The only thing that did work, sort of, is Ctrl+Z, but it doesn't actually kill/exit the program, but simply puts it in a background and then you still have to do kill %1 to actually kill it.
Thanks!
75 Answers
Note: Answer andded after comments...
I'm pretty sure it will kill most terminal programs; of course, it won't kill the ones that fork a new process, then return the prompt immediately.
Some programs may catch this interrupt and handle it however they want, or even ignore it. It may depend a lot on whether the program is designed to be run in a terminal or from a GUI.
A few of the programs I just tried in 10.04 and 11.10 that will end are:
ping - which runs continuously by default, so this is the only way to stop it;
find - often takes a long time, so it's useful to be able to end it.
gedit 0 Actually, many programs will not stop on Ctrl+C because all it does is create an exception in currently running thread. Multithread programs as well as programs with "In case of any exception, go on forward." sort of instructions will continue.
The proper case of actions will be either one of:
- Use
Ctrl + Breakkey combo. - Press
Ctrl + Z. This will not stop program but will return you the command prompt. Then, dops -ax | grep *%program_name%*. Find the line corresponding to the one yopu want to stop. The first integer in line will be program ID. Dokill -9 %id%to finally stop it. - If program also eats a lot of resources, you can use
topcommand in a separate terminal to see the ID faster.
I have faced this problem with one of my user having 10.04. The same issue has been discussed here CTRL+C no longer works in terminal
You can however terminate command using CTRL+SHIFT+C
It seems like copy-to-clipboard and terminate commands switched their keyboard shortcuts.
3If you know the program's name, you can use pkill in another terminal. For example, if the program's name is mutt:
pkill muttwill terminate the mutt program who wouldn't respond to CTRL + C
First: top (See the PID number of the program that you want to kill its run.)
Second: kill PID