karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [karaf] branch master updated: [KARAF-6171] Fix client in batch mode (-b)
Date Fri, 08 Mar 2019 10:54:43 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre 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 a332fe3  [KARAF-6171] Fix client in batch mode (-b)
     new 7dabd1f  Merge pull request #775 from jbonofre/KARAF-6171
a332fe3 is described below

commit a332fe3da223396c798cdce2e5de89ef338e12bd
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
AuthorDate: Fri Mar 8 07:29:39 2019 +0100

    [KARAF-6171] Fix client in batch mode (-b)
---
 .../main/java/org/apache/karaf/client/Main.java    | 28 ++++++++++++----------
 1 file changed, 15 insertions(+), 13 deletions(-)

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 e9e6336..65e0a0a 100644
--- a/client/src/main/java/org/apache/karaf/client/Main.java
+++ b/client/src/main/java/org/apache/karaf/client/Main.java
@@ -191,22 +191,24 @@ 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;
+                    if (!config.isBatch()) {
+                        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
                                     }
-                                    Thread.sleep(1000);
-                                } catch (Exception e) {
-                                    //ignore
                                 }
                             }
-                        }
-                    }.start();
+                        }.start();
+                    }
                     channel.setAgentForwarding(true);
                     NoCloseOutputStream output = new NoCloseOutputStream(terminal.output());
                     channel.setOut(output);


Mime
View raw message