Wednesday, April 3, 2019

linux - Way to kill frozen application



I have an application that freezes. I can't terminate it with ^C, so I have to do following:



$ ./myapp 
^C^Z

[1]+ Stopped ./myapp
$ pgrep -lf myapp
18479 bash ./myapp
$ kill -9 18479
$ fg
bash: fg: job has terminated
[1]+ Killed ./myapp
$



It is OK to do it in rare cases. But if I'm an author of this application and try to drill-down problem that causes freeze, it is very annoying to do this over and over again. Is there a way to save few keystrokes in such scenario?



Update:



pgrep + kill could be replaced with pkill -f -9 myapp, thanks to Lee B



Ideally I want to shorten path to just one keystroke, like ^C. It doesn't matter on what level it is implemented: on gnome terminal, on bash, wherever.


Answer



If Ctrl-C doesn't work, you should be able to use Ctrl-\, which will send a KILL signal, rather than the TERM signal that ctrl-c sends.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...