You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2016/07/29 06:52:13 UTC

karaf git commit: [KARAF-4596] Ctrl+C does not interrupt the thread running the job correctly

Repository: karaf
Updated Branches:
  refs/heads/master c4cec085c -> 4d335611a


[KARAF-4596] Ctrl+C does not interrupt the thread running the job correctly

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/4d335611
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/4d335611
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/4d335611

Branch: refs/heads/master
Commit: 4d335611af2a7256511e35ddeb3eef970e060b96
Parents: c4cec08
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Jul 28 17:38:17 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Jul 28 17:40:46 2016 +0200

----------------------------------------------------------------------
 .../apache/karaf/shell/impl/console/ConsoleSessionImpl.java | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/4d335611/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
index d338f47..2a10396 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
@@ -32,6 +32,7 @@ import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.felix.gogo.api.Job;
 import org.apache.felix.service.command.CommandProcessor;
 import org.apache.felix.service.command.CommandSession;
 import org.apache.felix.service.command.Converter;
@@ -54,6 +55,7 @@ import org.jline.reader.UserInterruptException;
 import org.jline.reader.impl.LineReaderImpl;
 import org.jline.reader.impl.history.history.FileHistory;
 import org.jline.reader.impl.history.history.MemoryHistory;
+import org.jline.terminal.Terminal.Signal;
 import org.jline.terminal.impl.DumbTerminal;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -258,6 +260,13 @@ public class ConsoleSessionImpl implements Session {
             Properties brandingProps = Branding.loadBrandingProperties(terminal);
             welcome(brandingProps);
             setSessionProperties(brandingProps);
+            jlineTerminal.handle(Signal.INT, s -> {
+                Job current = session.foregroundJob();
+                if (current != null) {
+                    current.interrupt();
+                }
+            });
+
             String scriptFileName = System.getProperty(SHELL_INIT_SCRIPT);
             executeScript(scriptFileName);
             while (running) {