Junior
How to politely shut down a process on Linux?
sobes.tech AI
Answer from AI
In Linux, a polite process termination is achieved by sending the SIGTERM signal (signal 15). This signal informs the process that it should terminate, allowing it to release resources and save data properly.
The command for this:
kill -15 <pid>
Or simply:
kill <pid>
If the process does not respond to SIGTERM, you can use the more forceful SIGKILL (signal 9), which will terminate the process without cleanup:
kill -9 <pid>
Thus, the correct order is:
- Send SIGTERM
- Wait, and if the process does not terminate, send SIGKILL
You can also use pkill or killall to terminate by process name.