kill process with care
November 18th, 2006 mysurface Posted in Common, kill, killall, pkill, sudo | Hits: 136140 | 15 Comments »
A lots of people likes to do kill -9, which means kill a process by force. By specified -9, process will be terminated by force, which is very fast and confirm kill but it leaves hidden side effects. Refers to Useless use of kill -9, kill a process by specified -9 may leave child processes of a parent orphaned, temporary files open, shared memory segments active, and sockets busy. This leaves the system in a messy state, and could lead to unanticipated and hard to debug problems.
How to kill a process?
To kill a process, you need to know its process ID (PID). The easiest way to check is by ps with grep, let say I wanna check the PID of gaim.
ps aux | grep gaim
Let say it returns PID with numbers 5678, Then now you can kill and check with ps and grep again to confirm whether the process have successfully kill.
kill 5678
Alternatively, you can kill processes by specified process name using pkill, again I wanna kill gaim.
pkill gaim
How to force kill a process?
You can choose a signal to send to the process, checks the kill manual for available signals to send.
man kill
Usually if you process was unable to kill, first check whether you need to have root privilege to kill? certain process is instantiate by root, to kill you must have the same level of privilege.
sudo kill 5678
Second, try to kill with -1 and -2 before uses -9.
kill -1 5678
Okay, the process is really irritating, let me force kill it,
kill -9 5678
Some process may have multiple instances, killing the process one by one with PID is nightmare, so kill them all one shot!
killall gaim
Still there? grrrrrrrrrr!
sudo killall -9 gaim
Haha this is just an example, anyway you usually no need to perform a force kill like that.







November 18th, 2006 at 6:36 pm
lol dat was funny
you can also use
sudo kill -KILL pid
December 7th, 2006 at 9:48 pm
[...] As intoduce in this post, you can kill any process with its PID. But what if you want kill a GUI-based program? You can use this: [...]
May 17th, 2007 at 12:56 am
[...] Core dump will be generated automatically if a program crashed due to segmentation fault or some other reason. But core dump will not be generated if an application halt and been terminate by control+c or conventional way of kill or pkill. Therefore, how we are going to investigate the reason of the halt process? There is an option that you can gdb a current running process by specified the GID. But what if you are not the author of the program? You are just a support engineer who wants to escalate the bugs to development team by providing the core file, what can you do? [...]
October 10th, 2008 at 3:32 am
believe me or not, i ran into a strange problem on ubuntu 8: put in a scratched CD, refused to read it. tryied to open a text file, processor load 100%, CD cannot be ejected or unmounted, killall -9 gedit has no effect, and even afeter removing the CD by force from drive, the process is still there with 100% load..
November 14th, 2008 at 2:24 pm
Can any one help me how to kill process by reading the process id from file
June 4th, 2010 at 4:00 am
Can any help how to connect dialup internert to ubuntu 8.10
March 12th, 2011 at 1:09 am
Missed period
March 12th, 2011 at 1:11 am
Hi, I am not able to see your site correctly inside of Chrome browser, I am hoping you can look into fixing this.
May 14th, 2011 at 4:45 pm
Cosy to run out of methods that undoubtedly affair, appreciation again!
May 18th, 2011 at 9:26 pm
Spot on with this write-up, I really assume this web site needs much more consideration. I’ll most likely be again to learn rather more, thanks for that info.
May 19th, 2011 at 2:13 am
Hey there webmaster! This might be an unusual way to contact you, but I assure you that you’ll want to hear what I have to say. I’ve been doing internet search engine ranking optimization for years now, and I’m constantly searching for better ways to help my wordpress clients. I’ve recently had a breakthrough in developing such a tool – and I can guarantee you that this tool will make you rank higher in Google for whatever keyword you want.. within days! Check it out here through this comment’s link. Good luck to you and I wish you success for your future endeavours!
May 19th, 2011 at 3:27 am
The following is something that should be read by everyone. I wouldn’t blame you if you were to turn and run as soon as you hear the word ‘free’ mentioned. However, this is something that I am sharing because I already know how it works. Companies give stuff away all the time and this site just has all these offers in one place and makes it easy for you to take advantage of each offer. You can just search through all the free offers by category until you find something that interests you or you can just take advantage of each and every offer. What keeps the site going is the memberships but you don’t have to become a member. You can go the free route on that one as well. As a free member, you can still get the 5 latest free offers each week, at zero cost to you. You don’t have to jump through any hoops in order to take advantage of the free offers. Of course, for each free offer that you want to take advantage of, you need to fill in your name and address so that they can ship the stuff to you. Also, and this might be the best part, if you actually pay the $25 to be a member, you can market this stuff to the world and make money giving away free stuff! As a paying member, you also get instant access to thousands of free offers, you’re automatically entered into the payout matrix and much more. The business plan ($25) gives you access to the video mailer that you can use for your free stuff business as well as any other business you have, business cards and other promotional tools. Just give it a look and let me know what you think. http://affops.com/go/to/12
May 19th, 2011 at 5:09 am
Thanks very good for report, I follow your blog
August 25th, 2011 at 12:30 pm
I do agree with all the ideas you’ve introduced on your post. They’re really convincing and will definitely work. Nonetheless, the posts are very quick for starters. Could you please lengthen them a little from subsequent time? Thank you for the post.
November 14th, 2011 at 5:46 am
Asus is coming out with accessories for the Eee Pad Transformer, including a Mini HDMI to VGA cable. Though in the meantime you could get a HDMI to VGA converter as a inter-rum solution.