From 5d022058c4fb2f448eee35d6df7f508c24d2a0be Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 6 Jan 2011 19:47:38 +0000 Subject: 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. --- src/jline/src/main/java/jline/TerminalSupport.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/jline') 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); -- cgit v1.2.3