kill -9 is the last resort when killing a process. What is the first resort?
09:09 21 Aug 2019

Background

For a while, whenever I did not know how to kill a process, I would use kill -9 by default. However, I have been told that this is the option of last resort, since -9 cannot be ignored according to the signal specifications:

‘KILL’

  1. Kill (cannot be caught or ignored).

Attempted methods

In the past, I have also tried the following methods

  1. Ctrl-C (or the SIGINT signal).
  2. Ctrl-Z (or the the SIGTSTP signal), followed by a ps -ef | grep username, then a kill -9 of the process.

From a coding technique perspective, what is the first resort when killing a process?

linux kill-process