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?

3 comments
Comment actions Permalink

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

0
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. 

ty,

Leonid.

0
Comment actions Permalink

It's not supported for Debug, please vote for https://youtrack.jetbrains.com/issue/IDEA-75946.

0

Please sign in to leave a comment.