diff options
Diffstat (limited to 'src/jline')
-rw-r--r-- | src/jline/src/main/java/jline/TerminalSupport.java | 16 |
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); |