Just looking ahead to see how the Linux/toybox/toolbox tops differ...

-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
From 927bacb1d5125674cf253f7c451edde2b0c6662c Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Thu, 12 Nov 2015 21:50:38 -0800
Subject: [PATCH] Fix top(1) help and add -H.

---
 toys/pending/top.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/toys/pending/top.c b/toys/pending/top.c
index fd7e879..519f66d 100644
--- a/toys/pending/top.c
+++ b/toys/pending/top.c
@@ -6,29 +6,28 @@
  *
  * No Standard
 
-USE_TOP(NEWTOY(top, ">0d#=3n#<1mb", TOYFLAG_USR|TOYFLAG_BIN))
+USE_TOP(NEWTOY(top, ">0d#=3n#<1bHm", TOYFLAG_USR|TOYFLAG_BIN))
 
 config TOP
   bool "top"
   default n
   help
-    
-    usage: top [-mb] [ -d seconds ] [ -n iterations ]
+    usage: top [-bHm] [ -d seconds ] [ -n iterations ]
 
     Provide a view of process activity in real time.
+
     Keys
        N/M/P/T show CPU usage, sort by pid/mem/cpu/time
-       S       show memory
        R       reverse sort
-       H       toggle threads
        C,1     toggle SMP
        Q,^C    exit
 
     Options
-       -n Iterations before exiting
-       -d Delay between updates
-       -m Same as 's' key
-       -b Batch mode
+    -b	Batch mode
+    -d	Delay between updates
+    -H	Show threads ('h' key interactively)
+    -m	Show memory ('s' key interactively)
+    -n	Iterations before exiting
 */
 
 #define FOR_top
@@ -44,7 +43,6 @@ GLOBALS(
   long reverse;
   long rows;
   long smp;
-  long threads;
   long m_flag;
   long num_new_procs;
   long scroll_offset;
@@ -415,7 +413,7 @@ static void read_procs(void) // Read Processes
     }
     add_proc(proc_num++, proc);
 
-    if (TT.threads) {
+    if (toys.optflags & FLAG_H) {
       char filename[64];
       uid_t uid = proc->uid;
 
@@ -790,7 +788,7 @@ void top_main(void )
         TT.m_flag = 0;
         break;
       case 'h':
-        if (!TT.m_flag) TT.threads ^= 1;
+        if (!TT.m_flag) toys.optflags ^= FLAG_H;
         break;
       case 'm':
         proc_cmp = &proc_vss_cmp;
-- 
2.6.0.rc2.230.g3dd15c0

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to