IDEA: ShutdownHook does not work in windows on Ctrl-F2


In windows when i stop Intellij debugging by Ctrl-F2, registered shutdown hook does not works:
Runtime.getRuntime().addShutdownHook(object : Thread() {
override fun run() {"program stopped") }

In windows console when stopping by Ctrl-C hook works good

In linux everything works good in both cases.

Any help?

Comment actions Permalink

Do you mean the Exit button on the run tool window?

Comment actions Permalink

No, what i'm talking about is Debug tool window not Run, and there is no Exit button in debug tool window. The thing what i need is to execute some code on debugging (Shift+F9) program exit (save data to db). To get this i'm using addShutdownHook() that works perfectly on linux (ubuntu 16.04) and doesnt work on Windows Server 2012. If i run (Shift+F10) module everything works. It seems that IDEA doesnt send interrupt signal to debugged module on Windows. My project based on Gradle/Kotlin configuration. 



Comment actions Permalink

It's not supported for Debug, please vote for


Please sign in to leave a comment.