Date
Dec. 23rd, 2024
 
2024年 11月 23日

Post: UNIX/Linux Command: When should I not kill 9 a process

UNIX/Linux Command: When should I not kill 9 a process

Published 12:09 Sep 18, 2015.

Created by @ezra. Categorized in #Technology, and tagged as #UNIX/Linux.

Source format: Markdown

Table of Content

Q:

I am always very hesitant to run kill -9, but I see other admins do it almost routinely.

I figure there is probably a sensible middle ground, so:

When and why should kill -9 be used? When and why not?
What should be tried before doing it?
What kind of debugging a "hung" process could cause further problems?

A:

Randal Schwartz used to frequently post "Useless use of (x)" on lists. One such post was about kill -9. It includes reasons and a recipe to follow. Here is a reconstructed version (quoted below).

(Quote abomination)

No no no. Don't use kill -9.

It doesn't give the process a chance to cleanly:

1) shut down socket connections

2) clean up temp files

3) inform its children that it is going away

4) reset its terminal characteristics

and so on and so on and so on.

Generally, send 15, and wait a second or two, and if that doesn't work, send 2, and if that doesn't work, send 1. If that doesn't, REMOVE THE BINARY because the program is badly behaved!

Don't use kill -9. Don't bring out the combine harvester just to tidy up the flower pot.

Just another Useless Use of Usenet,

(.signature)

原文链接

Pinned Message
HOTODOGO
The Founder and CEO of Infeca Technology.
Developer, Designer, Blogger.
Big fan of Apple, Love of colour.
Feel free to contact me.
反曲点科技创始人和首席执行官。
开发、设计与写作皆为所长。
热爱苹果、钟情色彩。
随时恭候 垂询