Search code examples
javashutdown-hookapplication-shutdown

addshutdownHook is not invoked when sending a QUIT signal


I would like to terminate the Java application when 'kill -s 3 ' is executed. But Java dumps the thread information instead. Do I need to use different kill signal?


Solution

  • According to JVMs and kill signals, the ShutdownHook is not run and the jvm is not shutdown when using signal SIGQUIT (3). Just use the default signal SIGTERM (15).