diff options
author | Denys Vlasenko | 2015-10-14 22:29:52 +0200 |
---|---|---|
committer | Denys Vlasenko | 2015-10-14 22:30:47 +0200 |
commit | 4ad702c0a70628ce7574609087e50b0ce40455d6 (patch) | |
tree | cf2a6dd837ea8f1ec62c3b239e34cb9a37b6f52e /procps | |
parent | 926d801fa51717b3af3faf33f9d686e92a20ecfd (diff) | |
download | busybox-4ad702c0a70628ce7574609087e50b0ce40455d6.zip busybox-4ad702c0a70628ce7574609087e50b0ce40455d6.tar.gz |
top: make sort field for 's' mode less confusing
function old new delta
display_topmem_process_list 542 565 +23
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r-- | procps/top.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/procps/top.c b/procps/top.c index 9a3f171..ddf794d 100644 --- a/procps/top.c +++ b/procps/top.c @@ -829,10 +829,17 @@ static NOINLINE void display_topmem_process_list(int lines_rem, int scr_width) #define HDR_STR " PID VSZ VSZRW RSS (SHR) DIRTY (SHR) STACK" #define MIN_WIDTH sizeof(HDR_STR) const topmem_status_t *s = topmem + G_scroll_ofs; + char *cp, ch; display_topmem_header(scr_width, &lines_rem); + strcpy(line_buf, HDR_STR " COMMAND"); - line_buf[11 + sort_field * 6] = "^_"[inverted]; + /* Mark the ^FIELD^ we sort by */ + cp = &line_buf[5 + sort_field * 6]; + ch = "^_"[inverted]; + cp[6] = ch; + do *cp++ = ch; while (*cp == ' '); + printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, line_buf); lines_rem--; @@ -1172,10 +1179,8 @@ int top_main(int argc UNUSED_PARAM, char **argv) ntop = 0; while ((p = procps_scan(p, scan_mask)) != NULL) { int n; -#if ENABLE_FEATURE_TOPMEM - if (scan_mask != TOPMEM_MASK) -#endif - { + + IF_FEATURE_TOPMEM(if (scan_mask != TOPMEM_MASK)) { n = ntop; top = xrealloc_vector(top, 6, ntop++); top[n].pid = p->pid; @@ -1215,7 +1220,7 @@ int top_main(int argc UNUSED_PARAM, char **argv) break; } - if (scan_mask != TOPMEM_MASK) { + IF_FEATURE_TOPMEM(if (scan_mask != TOPMEM_MASK)) { #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE if (!prev_hist_count) { do_stats(); @@ -1229,17 +1234,13 @@ int top_main(int argc UNUSED_PARAM, char **argv) #else qsort(top, ntop, sizeof(top_status_t), (void*)(sort_function[0])); #endif + display_process_list(G.lines, col); } #if ENABLE_FEATURE_TOPMEM else { /* TOPMEM */ qsort(topmem, ntop, sizeof(topmem_status_t), (void*)topmem_sort); - } -#endif - if (scan_mask != TOPMEM_MASK) - display_process_list(G.lines, col); -#if ENABLE_FEATURE_TOPMEM - else display_topmem_process_list(G.lines, col); + } #endif clearmems(); if (iterations >= 0 && !--iterations) @@ -1248,7 +1249,7 @@ int top_main(int argc UNUSED_PARAM, char **argv) sleep(interval); #else scan_mask = handle_input(scan_mask, interval); -#endif /* FEATURE_USE_TERMIOS */ +#endif } /* end of "while (not Q)" */ bb_putchar('\n'); |