Skip to content

[Solved] Linux kill -9 Cannot Kill The Process

Last Updated on 2022-08-17 by Clay

The kill command is a useful command in Linux. Many times when we developing or executing program, we had got the program stuck problem.

At this time, we can find the PID code that is automatically assigned to process, and then terminate it with kill command.

Then we will find out: Hey! The program was terminated, and our system is smooth again!

But this trick is not 100% effective. Let's look at the meaning of the signals we can send:

  • HUP 1 Terminal disconnection
  • INT 2 Interrupt (Ctrl + C)
  • QUIT 3 Exit (Ctrl + \)
  • TERM 15 Terminate
  • KILL 9 Forced Termination
  • CONT 18 Continue (opposite of STOP)
  • STOP 19 Pause (Ctrl + Z)

The default kill is actually the general termination of the preset signal 15. When we use general termination to stop the process, if it is confirmed that cancel the process will not affect (For example, the stuck program is developed by you at all), we will start to try use kill -9 to perform a "force kill".

kill -9 <PID>


But today when I killed the process with kill -9, I encountered a situation that the process cloud not be terminated successfully.

And the program doesn't stop automatically. Finally, after groping for a while, I managed to find a solution.


Solution - Kill the parent process

One possibility is that although we asked the process to stop getting stuck and free resources, its parent process is still calling it, so we cannot kill the process.

Then the solution is simple. We directly kill the parent itinerary.

Again, you really need to make sure it doesn't affect your system to do it.

First, you first find the PID of the trip you want to kill, let's say 200330.

Then, we can use the following command to see its status:

cd /proc/200330
cat status | grep PPid

The PPid you see is the PID of its parent process. Then, just kill the parent process.


References


Read More

Tags:

Leave a Reply