Lost in technical reverie

Lost in technical reverie
Helping solve technical issues, digital musings, and the odd rant.

Tuesday, January 21, 2014

killall - All bark and no bite? Why does killall not kill at all.

It's a rare occurrence that I kill processes on my Linux boxes. Processes exit or close normally. The odd time Firefox on my desktop, or Apache on a server needs an extra kick.

killall is a handy utility for finding the process IDs of all processes matching your specification and killing them. If you have 4 Firefox instances running, you don't need to find their process IDs in your process tree and laboriously kill each one. You just issue the command killall firefox

However, you'll have noticed it doesn't always kill a process, and some folks tend to blame killall. This is most likely due to the fact they didn't RTFM.

The default killall operation issues a SIGTERM to the process. Once the process receives the notice, it should clean up and exit. But if your process has crashed or has run away, it will never receive the notice or it's completely ignored. killall does not live up to it's name sake. One by one you start issuing kill -9 commands....

When you issue the kill command the appending '-9' infroms kill to send a SIGKILL, and this is the key point. We need to tell killall to send SIGKILL and not the polite SIGTERM.

So you can use:

> killall -s SIGKILL firefox

or

> killall -9 firefox

You should not however issue kill -9 or killall -9 unless your processes have not responded to the SIGTERM command. You should always attempt to shutdown application gracefully.

1 comment:

  1. happy new blog.

    i can't remember the last time i used kill. normally it is just a web browser that needs killing.. and rather than htop or whatever to find out the pid, killall is indeed a quicker way. haven't found a way to stop aplay, so it gets killalled too.

    a note on the blog.. there is no option to sign by name, only by all these other ids.. don't know if that's how you want it or if it's changable.

    i shall read more now.

    steve

    ReplyDelete