linux command of the difference between kill and kill -9

linux command of the difference between kill and kill -9

Reprinted from https://www.cnblogs.com/liuhouhou/p/5400540.html

 

 

I am sure you are very familiar with the kill -9, they are often used at work. Especially when you go to restart tomcat. But mostly it seems, our understanding of -9 only the surface of it.

Few people (including me) to look seriously kill -n n in the end this is what stuff. Self-criticism about.

Ok. Let's good to know about this familiar stranger.

1)kill

From the help you can clearly see the -n refers to the signal number, then the question is, "No signal" Who is the god? ? ?

2) kill -l (see Linux / Unix signal variable)

So much ah! ! Today alone talk about SIGTERM and SIGKILL

3)(kill pid) 、( kill -15 pid)

The system program will send a signal to the corresponding SIGTERM. When the program receives this signal, the following things will happen

  1. Program immediately stop
  2. When the program stops and then release the appropriate resources
  3. The program may continue to run

      Most of the program after receiving the SIGTERM signal, will first release their own resources, and then stop. But there are also programs may, after receiving the semaphore and do some other things, and these things can be

      Configuration. If the program is waiting for IO, you may not immediately make the appropriate.

  That is to say, SIGTERM mostly be blocked, ignored.

4)kill  -9 pid

You can not not respond to SIGTERM it? ? Well, I will give you a kill order, I see you do not obediently. Most admin can use this command

However, not all programs will obediently toe the line, there is always a program in those states not appropriate immediately.

 

appendix:

linux signals

Signal Name Number Description
Sigःuf 1 Hangup (POSIX)
SIGINT 2 Terminal interrupt (ANSI)
SIGQUIT 3 Terminal quit (POSIX)
SEAL 4 Illegal instruction (ANSI)
SIGTRAP 5 Trace trap (POSIX)
SIGIOT 6 IOT Trap (4.2 BSD)
SIGBUS 7 BUS error (4.2 BSD)
SIGFPE 8 Floating point exception (ANSI)
SIGKILL 9 Kill(can't be caught or ignored) (POSIX)
SIGUSR1 10 User defined signal 1 (POSIX)
SIGSEGV 11 Invalid memory segment access (ANSI)
SIGUSR2 12 User defined signal 2 (POSIX)
SIGPIPE 13 Write on a pipe with no reader, Broken pipe (POSIX)
SIGALRM 14 Alarm clock (POSIX)
SIGTERM 15 Termination (ANSI)
SIGSTKFLT 16 Stack fault
SIGCHLD 17 Child process has stopped or exited, changed (POSIX)
SIGCONT 18 Continue executing, if stopped (POSIX)
SIGSTOP 19 Stop executing(can't be caught or ignored) (POSIX)
SIGTSTP 20 Terminal stop signal (POSIX)
SIGTTIN 21 Background process trying to read, from TTY (POSIX)
SIGTTOU 22 Background process trying to write, to TTY (POSIX)
Sigurd 23 Urgent condition on socket (4.2 BSD)
SIGXCPU 24 CPU limit exceeded (4.2 BSD)
SIGXFSZ 25 File size limit exceeded (4.2 BSD)
SIGVTALRM 26 Virtual alarm clock (4.2 BSD)
SIGPROF 27 Profiling alarm clock (4.2 BSD)
SIGWINCH 28 Window size change (4.3 BSD, Sun)
SIGIO 29 I/O now possible (4.2 BSD)
SIGPWR 30 Power failure restart (System V)

Guess you like

Origin www.cnblogs.com/shoshana-kong/p/11106574.html