[ 
https://issues.apache.org/jira/browse/KARAF-5689?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16566819#comment-16566819
 ] 

ASF GitHub Bot commented on KARAF-5689:
---------------------------------------

gnodet closed pull request #585: [KARAF-5689] Console is broken after Ctrl+C
URL: https://github.com/apache/karaf/pull/585
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 0f11f65423..cf41a620e3 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
@@ -154,9 +154,7 @@ public ConsoleSessionImpl(SessionFactory factory,
         brandingProps = 
Branding.loadBrandingProperties(terminal.getClass().getName().endsWith("SshTerminal"));
 
         // Create session
-        session = processor.createSession(jlineTerminal.input(),
-                jlineTerminal.output(),
-                jlineTerminal.output());
+        session = processor.createSession(in, out, err);
 
         // Completers
         Completer builtinCompleter = createBuiltinCompleter();
diff --git 
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
 
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
index e31d606202..261ca8de95 100644
--- 
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
+++ 
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
@@ -18,6 +18,7 @@
  */
 package org.apache.karaf.shell.impl.console.osgi;
 
+import java.io.OutputStream;
 import java.io.PrintStream;
 import java.nio.charset.Charset;
 import java.security.PrivilegedAction;
@@ -32,6 +33,7 @@
 import org.apache.karaf.shell.impl.console.JLineTerminal;
 import org.apache.karaf.shell.support.ShellUtil;
 import org.apache.karaf.util.jaas.JaasHelper;
+import org.apache.sshd.common.util.io.NoCloseOutputStream;
 import org.jline.terminal.Terminal;
 import org.jline.terminal.TerminalBuilder;
 import org.osgi.framework.BundleContext;
@@ -68,10 +70,16 @@ public void start() throws Exception {
         final Subject subject = createLocalKarafSubject();    
         this.session = JaasHelper.doAs(subject, (PrivilegedAction<Session>) () 
-> {
             String encoding = getEncoding();
+            PrintStream pout = new PrintStream(terminal.output()) {
+                @Override
+                public void close() {
+                    // do nothing
+                }
+            };
             session = sessionFactory.create(
                                   terminal.input(),
-                                  new PrintStream(terminal.output()),
-                                  new PrintStream(terminal.output()),
+                                  pout,
+                                  pout,
                                   new JLineTerminal(terminal),
                                   encoding,
                                   LocalConsoleManager.this::close);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Console is broken after Ctrl+C
> ------------------------------
>
>                 Key: KARAF-5689
>                 URL: https://issues.apache.org/jira/browse/KARAF-5689
>             Project: Karaf
>          Issue Type: Bug
>    Affects Versions: 4.1.3, 4.2.0
>            Reporter: Guillaume Nodet
>            Assignee: Guillaume Nodet
>            Priority: Major
>             Fix For: 4.2.1
>
>
> Hitting Ctrl+C soon after running a long command (like {{bundle:classes}}) 
> seems to kill the console.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to