IDEA: ShutdownHook does not work in windows on Ctrl-F2
Answered
In windows when i stop Intellij debugging by Ctrl-F2, registered shutdown hook does not works:
Runtime.getRuntime().addShutdownHook(object : Thread() {
override fun run() { log.info("program stopped") }
})
In windows console when stopping by Ctrl-C hook works good
In linux everything works good in both cases.
Any help?
Please sign in to leave a comment.
Do you mean the Exit button on the run tool window?
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.
ty,
Leonid.
It's not supported for Debug, please vote for https://youtrack.jetbrains.com/issue/IDEA-75946.