Remove the shutdown hook when it's done

This commit is contained in:
Eugene Yokota 2018-06-14 05:09:00 -04:00
parent 51ee6fc409
commit e3c9eb0cd9
1 changed files with 12 additions and 2 deletions

View File

@ -115,10 +115,20 @@ object StandardMain {
val previous = TrapExit.installManager()
try {
try {
try {
val hooked = try {
Runtime.getRuntime.addShutdownHook(shutdownHook)
true
} catch {
case _: IllegalArgumentException => false
}
try {
MainLoop.runLogged(s)
} finally exchange.shutdown
} finally {
exchange.shutdown
if (hooked) {
Runtime.getRuntime.removeShutdownHook(shutdownHook)
}
}
} finally DefaultBackgroundJobService.backgroundJobService.shutdown()
} finally TrapExit.uninstallManager(previous)
}