From da85255f8e8e3f8a279ce5c3140fa1cc8809aa15 Mon Sep 17 00:00:00 2001 From: dmharrah Date: Thu, 16 Jul 2009 13:31:46 +0000 Subject: [PATCH] Properly emulate main thread exceptions terminating application even if other threads are running git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@866 d89573ee-9141-11dd-94d4-bdf5e562f29c --- src/main/scala/sbt/TrapExit.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/scala/sbt/TrapExit.scala b/src/main/scala/sbt/TrapExit.scala index aef7cebb5..43a63615d 100644 --- a/src/main/scala/sbt/TrapExit.scala +++ b/src/main/scala/sbt/TrapExit.scala @@ -30,7 +30,13 @@ object TrapExit val originalThreads = allThreads val code = new ExitCode val customThreadGroup = new ExitThreadGroup(new ExitHandler(Thread.getDefaultUncaughtExceptionHandler, originalThreads, code, log)) - val executionThread = new Thread(customThreadGroup, "run-main") { override def run() { execute } } + val executionThread = + new Thread(customThreadGroup, "run-main") + { + override def run(): Unit = + try { execute } + catch { case e => log.trace(e); System.exit(1) } // an exception in the main thread causes the whole program to terminate + } val originalSecurityManager = System.getSecurityManager try