Reputation: 15755
Sometimes, we will face that we try to kill a java process, but the process does not terminate, we have to send kill -9 to terminate it.
Questsion:
Upvotes: 0
Views: 1663
Reputation: 98284
When a Java process, or more precisely HotSpot JVM, receives signal 15 (SIGTERM), it initiates shutdown sequence. One of its essential steps is the invocation of Shutdown hooks.
Shutdown hooks are regular Java threads. By the convention, they should finish their work quickly, but sometimes (just like regular Java code) shutdown hooks may loop, block, wait for something or otherwise delay the termination. JVM will hang until all shutdown hooks complete.
Use jstack
utility to find what prevents the timely termination. Look for SIGTERM handler
thread in a thread dump - it will be probably waiting for some other (offender) thread to complete. JVM will not exit normally while the offender thread is running.
Upvotes: 2
Reputation: 990
kill -15
: Send SIGTERM, kill the process, but allow it to do some cleanup first. Peaceful terminating.
Waiting for i/o and so on.
Upvotes: 1