aboutsummaryrefslogtreecommitdiff
path: root/stage1
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-09-15 12:18:00 +0100
committerChristopher Vogt <oss.nsp@cvogt.org>2016-09-15 12:18:00 +0100
commitd2e7fcfd0b71a53f22a7e8fbcf5c920c1c689a00 (patch)
treecf0983aae763e084fd05c0c75fceca32453e9ae8 /stage1
parent32abe161b5454e2c9e9265bb5b95e8fad3c09bb3 (diff)
downloadcbt-d2e7fcfd0b71a53f22a7e8fbcf5c920c1c689a00.tar.gz
cbt-d2e7fcfd0b71a53f22a7e8fbcf5c920c1c689a00.tar.bz2
cbt-d2e7fcfd0b71a53f22a7e8fbcf5c920c1c689a00.zip
fix behavior of System.exit trapping
Installing one globally for the JVM live-time and make behavior dependent on a thread local variable seems safer than globally switching it out and having race conditions. Also now all other calls are forwarded to a potential Nailgun SecurityManager, which should fix some bugs.
Diffstat (limited to 'stage1')
-rw-r--r--stage1/Stage1Lib.scala6
1 files changed, 4 insertions, 2 deletions
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala
index 9e500a3..43c4f84 100644
--- a/stage1/Stage1Lib.scala
+++ b/stage1/Stage1Lib.scala
@@ -251,14 +251,16 @@ ${files.sorted.mkString(" \\\n")}
}
def trapExitCode( code: => ExitCode ): ExitCode = {
+ val trapExitCodeBefore = NailgunLauncher.trapExitCode.get
try{
- System.setSecurityManager( new TrapSecurityManager )
+ NailgunLauncher.trapExitCode.set(true)
code
} catch {
case CatchTrappedExitCode(exitCode) =>
+ logger.stage1(s"caught exit code $exitCode")
exitCode
} finally {
- System.setSecurityManager(NailgunLauncher.defaultSecurityManager)
+ NailgunLauncher.trapExitCode.set(trapExitCodeBefore)
}
}