karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject [karaf] branch master updated: [KARAF-5995]ensure there is a way to quit bin/client cmd
Date Wed, 31 Oct 2018 07:24:50 GMT
This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/master by this push:
     new d6d503d  [KARAF-5995]ensure there is a way to quit bin/client cmd
d6d503d is described below

commit d6d503d2a59304115e23922bde6f72611dd054f0
Author: Freeman Fang <freeman.fang@gmail.com>
AuthorDate: Wed Oct 31 15:24:36 2018 +0800

    [KARAF-5995]ensure there is a way to quit bin/client cmd
---
 client/src/main/java/org/apache/karaf/client/Main.java | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/client/src/main/java/org/apache/karaf/client/Main.java b/client/src/main/java/org/apache/karaf/client/Main.java
index 22cd50b..e9e6336 100644
--- a/client/src/main/java/org/apache/karaf/client/Main.java
+++ b/client/src/main/java/org/apache/karaf/client/Main.java
@@ -191,6 +191,22 @@ public class Main {
                 if (config.getCommand().length() > 0) {
                     ChannelExec channel = session.createExecChannel(config.getCommand() +
"\n");
                     channel.setIn(new ByteArrayInputStream(new byte[0]));
+                    new Thread() {
+                        public void run() {
+                            while (true) {
+                                try {
+                                    int a = System.in.read();
+                                    if (a == -1) {
+                                        channel.close(true);
+                                        break;
+                                    }
+                                    Thread.sleep(1000);
+                                } catch (Exception e) {
+                                    //ignore
+                                }
+                            }
+                        }
+                    }.start();
                     channel.setAgentForwarding(true);
                     NoCloseOutputStream output = new NoCloseOutputStream(terminal.output());
                     channel.setOut(output);
@@ -200,6 +216,7 @@ public class Main {
                     if (channel.getExitStatus() != null) {
                         exitStatus = channel.getExitStatus();
                     }
+                    
                 } else {
                     ChannelShell channel = session.createShellChannel();
                     Attributes attributes = terminal.enterRawMode();


Mime
View raw message