Middle+
How to kill a process in Linux? What to do if 'kill pid' doesn't help?
sobes.tech AI
Answer from AI
In Linux, a process can be killed using the kill command and specifying the PID (process ID):
kill <pid>
By default, the SIGTERM (15) signal is sent, which terminates the process gracefully.
If the process does not respond to SIGTERM, a more forceful SIGKILL (9) signal can be sent, which forcibly terminates the process:
kill -9 <pid>
If even kill -9 does not work, the process might be in a "D" (uninterruptible sleep) state, for example, waiting for I/O or blocked at the kernel level. In this case, the process cannot be killed until the system call completes or the resource is freed.
For diagnostics, you can use:
ps aux | grep <pid>— to check the process status (STAT column)toporhtop— process monitoringstrace -p <pid>— trace system calls of the process
If the process is stuck due to hardware or filesystem issues, the problem needs to be addressed at that level.