Cannot kill a java process
6,168
It's rare but possible for processes to end up in a D (uninterrupted sleep) state and they cannot be killed. You can check with:
ps -o cmd,stat -p <pid>
If the STAT is D, that's the issue.
If not I suggest you add some more information to your post such as exactly what the process is, what it is doing, and why you want to kill it.
Related videos on Youtube
Author by
Howard Stark
Updated on September 18, 2022Comments
-
Howard Stark over 1 year
I have a java process that cannot be killed. I have tried every method I know, or that I have found on the internet to no avail. I have tried:
killall java kill -9 <pid> kill -11 <pid> kill -6 <pid>
No matter what I try, I cannot kill the program. If this helps, it has a dynamic PID, and this has happened before and I somehow killed it last time.
-
amphibient over 11 yearsare you sure you are using the correct PID?
-
Marco over 11 yearsAre you sure the program is still alive and not a zombie? BTW: There is usually no reason to
kill -9
a process. Sending aSIGTERM
, thenSIGQUIT
orSIGINT
should make the program quit. If it doesn't it's buggy. -
tink over 11 yearsIt's also worth noting that it's often impossible to kill processes that are currently waiting on I/O.
-
goldilocks over 11 yearsDisagree with Marco about the use value of SIGKILL and the assertion that a program that responds to that but not SIGTERM is "buggy". $0.02
-
Marco over 11 years@goldilocks A program cannot respond to SIGKILL. Usually you want to give the program a change to clean up (close files, network connections, etc) and then exit and that's what SIGTERM is for. If you tell a program to terminate and it refuses, it's a bug! SIGINT or SIGQUIT should not be necessary, but some programs respond to the signals and exit immediately. SIGKILL is only useful if you want to prevent the program from cleaning up or in the rare case it got stuck in the clean-up code.
-
goldilocks over 11 years@Marco I am aware of how signal handling works, and the fact that "a program cannot respond to SIGKILL" is the use-value I was referring to. If SIGTERM does not work, use SIGKILL. The fact that a process hangs in clean-up on an arbitrary SIGTERM may or may not be evidence of a bug in that program -- it may also be due to explicit mis-use, problems with the system (IO), or a problem/bug in a shared component. Not responding to SIGTERM is not a good sign, but signs like that could be considered a feature as opposed to a bug, depending on the context.
-
Gilles 'SO- stop being evil' over 11 yearsWhat is the output of
ps l 1234
where 1234 is the process ID? -
manatwork over 11 yearsI have a Java program which occasionally gets immune to
SIGKILL
. In such cases I send it to background with Ctrl-Z whenkill -9 %1
works.
-