1833838 Members
2307 Online
110063 Solutions
New Discussion

Re: Kill

 
Santhikumari
Advisor

Kill

Could you please explain the difference between kill -9 and kill-15 commands
3 REPLIES 3
R.K. #
Honored Contributor

Re: Kill

Hi,

Refer following link to make it more clear:
http://docs.hp.com/en/B9106-90007/kill.1.html

In short:
9 SIGKILL Kill Forced termination; cannot be trapped

15 SIGTERM Terminate Terminate; can be trapped

-R.K.
Don't fix what ain't broke
Bill Hassell
Honored Contributor

Re: Kill

kill -9 is a VERY dangerous command because most beginner books use it way too generously. kill -9 stops the program from executing. It gives the program no chance to write memory information, or to close files properly. In a database program, this almost guarantees corruption and a long database recovery process.

The kill command does not actually kill the program. Instead, it is a signal to the program. This signal goes into the process table and the next time the program starts t run, it will see the signal. Now what happens next is completely under the control of the programmer (except kill -9, see below). The programmer can choose to completely ignore the signal in which system defaults will stop the program, and in the case of kill -3 or kill -11, the program will be forced to create a core dump.

But a senior programmer will always handle the different signals in an organized way. For instance, kill -15 (also, kill without any option = -15) might start a normal end of job and the process will close files and flush memory in a controlled way. A kill -1 is normally sent when the connection to the program is terminated (in the old days, the modem would disconnect or hang up), so a program might handle this condition in a slightly different way.

kill -9 should be used only as a last resort but it will do nothing if the process is not running, as in waiting for an I/O to complete. In badly written application programs, a network I/O is initiated without any timeout and when a problem occurs in the network, the program can never be killed. kill -9 sets the flag but the program isn't running.

SO tghe first command to stop a program would be to use kill (with no signal number) or kill -15. Check if the program has stopped with ps. If it has not stopped after 5-10 seconds, try kill -1 to signal the program that it has been disconnected from any terminal I/O. If there is a programmer that can read the core file, then use kill -3 if kill -15 and kill -1 do not work.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: Kill

Instead of Bill's kill -1, etc, you might want to use their names:
kill -HUP # -1
kill -QUIT # -3
kill -TERM # -15
Use "kill -l" to list.
You can continue to use -9. :-)