Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The JVM responds to signals on its own. Some will cause the JVM to shutdown gracefully, which includes running shutdown hooks. Other signals will cause the JVM to abort without running shutdown hooks.
Shutdown hooks are added using Runtime.addShutdownHook(Thread).
I don’t think the JDK provides an official way to handle signals within your Java application. However, I did find this IBM article, which describes using some undocumented
sun.misc.Signalclass to do exactly that. The article dates from 2002 and uses JDK 1.3.1, but I’ve confirmed that thesun.misc.Signalclass still exists in JDK 1.6.0.