diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-09-15 12:18:00 +0100 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-09-15 12:18:00 +0100 |
commit | d2e7fcfd0b71a53f22a7e8fbcf5c920c1c689a00 (patch) | |
tree | cf0983aae763e084fd05c0c75fceca32453e9ae8 /stage1 | |
parent | 32abe161b5454e2c9e9265bb5b95e8fad3c09bb3 (diff) | |
download | cbt-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.scala | 6 |
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) } } |