Merge pull request #4204 from eed3si9n/wip/fix-shutdownhook

Remove the shutdown hook when it's done
This commit is contained in:
eugene yokota 2018-06-14 07:21:31 -04:00 committed by GitHub
commit 21db286766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)
}