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() { 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?

0

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

0

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

请先登录再写评论。