karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [20/50] [abbrv] karaf git commit: [KARAF-4596] Ctrl+C does not interrupt the thread running the job correctly
Date Mon, 22 Aug 2016 09:30:18 GMT
[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/ddd7c911
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/ddd7c911
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/ddd7c911

Branch: refs/heads/master
Commit: ddd7c911005764b4c60ab99518492e1c9b97a3dd
Parents: 9c5b4c5
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Thu Jul 28 17:38:17 2016 +0200
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Mon Aug 22 11:29:20 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/ddd7c911/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) {


Mime
View raw message