2

what is the difference between kill -9 pid and kill pid command ? Do they have different behavior ? i know that -9 is for "SIGKILL" signal

muru
  • 193,181
  • 53
  • 473
  • 722
Rushikesh Gaidhani
  • 53
  • 1
  • 3
  • 11
  • If you don't specify a signal it will send SIGTERM (giving the process a chance to close itself down gracefully) – Zanna Jun 27 '16 at 06:47

1 Answers1

6

kill pid (which sends signal 15 (SIGTERM)) tells pid to terminate, but said program can execute some code first or even ignore the signal. kill -9 pid, on the other hand, forces the program to immediately terminate (it cannot be ignored).

You should always try kill pid first, as it allows the program to do things like saving/closing open files before exiting. Only use kill -9 when you need the program to close and it won't respond to a simple kill pid.

insert_name_here
  • 1,535
  • 9
  • 15