Reputation: 7356
I'm developing my application (on Linux) and sadly it sometimes hangs. I can use Ctrl+C
to send sigint, but my program is ignoring sigint because it's too far gone. So I have to do the process-killing-dance:
Ctrl+Z
$ ps aux | grep process_name
$ kill -9 pid
Is there a way to configure bash to send the kill signal to the current process when I press - say - Ctrl+Shift+C
?
Upvotes: 12
Views: 13132
Reputation: 340466
Given that there's no bound key for SIGKILL, what you can do is to create an alias to save some typing, if SIGQUIT doesn't cut it for you. First, the
Ctrl+Z
$ ps aux | grep process_name
$ kill -9 pid
dance can be summarized (if there's only one instance of the process that you want to kill) as
Ctrl+Z
$ pkill -9 process_name
if your use case always goes to suspend then kill, you can create an alias to kill the last process ran like
$alias pks="pkill -9 !!:0"
Add that alias in your ~/.bash_profile.
Upvotes: 2
Reputation: 42538
I don't think there is any key you can use to send a SIGKILL.
Will SIGQUIT do instead? If you are not catching that, the default is to core dump the process. By default this is ^\. You can see this by running:
$ stty -a
in a terminal. It should say:
quit = ^\
Upvotes: 10
Reputation: 36422
You can send a SIGQUIT signal to the current foreground process by pressing ^\ (by default, you can run stty -a
to see the current value for quit
.)
You can also kill the last backgrounded process from the shell by running
$ kill %%
Upvotes: 7