summaryrefslogtreecommitdiff
path: root/src/jline
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-06 19:47:38 +0000
committerPaul Phillips <paulp@improving.org>2011-01-06 19:47:38 +0000
commit5d022058c4fb2f448eee35d6df7f508c24d2a0be (patch)
treed5559585ad49acf14b979439258be07ccaf7fbe8 /src/jline
parent04f59ea9e8238cc9561a3281dfaa22808dc0a1b8 (diff)
downloadscala-5d022058c4fb2f448eee35d6df7f508c24d2a0be.tar.gz
scala-5d022058c4fb2f448eee35d6df7f508c24d2a0be.tar.bz2
scala-5d022058c4fb2f448eee35d6df7f508c24d2a0be.zip
The shutdown hook installed by jline has made l...
The shutdown hook installed by jline has made life difficult for sbt for a while. This changes jline not to install it, and alters the scala startup script to trap exit and re-enable echo on recognizably unix platforms. In addition it no longer installs a shutdown hook to flush the repl history to disk, instead flushing after every line. Any bash reviewers out there? Unless someone raises a hand, no review.
Diffstat (limited to 'src/jline')
-rw-r--r--src/jline/src/main/java/jline/TerminalSupport.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/jline/src/main/java/jline/TerminalSupport.java b/src/jline/src/main/java/jline/TerminalSupport.java
index 9448b0d481..ee7d2008ca 100644
--- a/src/jline/src/main/java/jline/TerminalSupport.java
+++ b/src/jline/src/main/java/jline/TerminalSupport.java
@@ -8,6 +8,7 @@
package jline;
import jline.internal.Log;
+import jline.internal.Configuration;
import java.io.IOException;
import java.io.InputStream;
@@ -24,12 +25,16 @@ public abstract class TerminalSupport
{
public static String DEFAULT_KEYBINDINGS_PROPERTIES = "keybindings.properties";
+ public static final String JLINE_SHUTDOWNHOOK = "jline.shutdownhook";
+
public static final int DEFAULT_WIDTH = 80;
public static final int DEFAULT_HEIGHT = 24;
private Thread shutdownHook;
+ private boolean shutdownHookEnabled;
+
private boolean supported;
private boolean echoEnabled;
@@ -38,6 +43,7 @@ public abstract class TerminalSupport
protected TerminalSupport(final boolean supported) {
this.supported = supported;
+ this.shutdownHookEnabled = Configuration.getBoolean(JLINE_SHUTDOWNHOOK, false);
}
public void init() throws Exception {
@@ -54,7 +60,14 @@ public abstract class TerminalSupport
init();
}
+ // Shutdown hooks causes classloader leakage in sbt,
+ // so they are only installed if -Djline.shutdownhook is true.
protected void installShutdownHook(final Thread hook) {
+ if (!shutdownHookEnabled) {
+ Log.debug("Not install shutdown hook " + hook + " because they are disabled.");
+ return;
+ }
+
assert hook != null;
if (shutdownHook != null) {
@@ -72,6 +85,9 @@ public abstract class TerminalSupport
}
protected void removeShutdownHook() {
+ if (!shutdownHookEnabled)
+ return;
+
if (shutdownHook != null) {
try {
Runtime.getRuntime().removeShutdownHook(shutdownHook);