kill -9 is the last resort when killing a process. What is the first resort?
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’
- Kill (cannot be caught or ignored).
Attempted methods
In the past, I have also tried the following methods
- Ctrl-C (or the SIGINT signal).
- 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?