This is an automated email from the ASF dual-hosted git repository.

snemeth pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 1ccba37  YARN-10490. yarn top command not quitting completely with 
ctrl+c. Contributed by Agshin Kazimli
1ccba37 is described below

commit 1ccba3734d1c46aaae1cd3dd4dd504e691771167
Author: Szilard Nemeth <snem...@apache.org>
AuthorDate: Thu Jan 21 20:30:19 2021 +0100

    YARN-10490. yarn top command not quitting completely with ctrl+c. 
Contributed by Agshin Kazimli
---
 .../src/main/java/org/apache/hadoop/yarn/client/cli/TopCLI.java  | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/TopCLI.java
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/TopCLI.java
index 79b1406..882d2bf 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/TopCLI.java
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/TopCLI.java
@@ -444,6 +444,7 @@ public class TopCLI extends YarnCLI {
 
   public static void main(String[] args) throws Exception {
     TopCLI topImp = new TopCLI();
+    topImp.addShutdownHook();
     topImp.setSysOutPrintStream(System.out);
     topImp.setSysErrPrintStream(System.err);
     int res = ToolRunner.run(topImp, args);
@@ -492,7 +493,6 @@ public class TopCLI extends YarnCLI {
         rmStartTime = getRMStartTime();
       }
     }
-    clearScreen();
     return 0;
   }
 
@@ -1220,4 +1220,11 @@ public class TopCLI extends YarnCLI {
     byte[] output = IOUtils.toByteArray(p.getInputStream());
     return new String(output, "ASCII");
   }
+
+  private void addShutdownHook() {
+    //clear screen when the program exits
+    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+      clearScreen();
+    }));
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to