diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-14 22:29:52 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-14 22:30:47 +0200 |
commit | 4ad702c0a70628ce7574609087e50b0ce40455d6 (patch) | |
tree | cf2a6dd837ea8f1ec62c3b239e34cb9a37b6f52e | |
parent | 926d801fa51717b3af3faf33f9d686e92a20ecfd (diff) | |
download | busybox-w32-4ad702c0a70628ce7574609087e50b0ce40455d6.tar.gz busybox-w32-4ad702c0a70628ce7574609087e50b0ce40455d6.tar.bz2 busybox-w32-4ad702c0a70628ce7574609087e50b0ce40455d6.zip |
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>
-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 9a3f171ac..ddf794d7d 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) | |||
829 | #define HDR_STR " PID VSZ VSZRW RSS (SHR) DIRTY (SHR) STACK" | 829 | #define HDR_STR " PID VSZ VSZRW RSS (SHR) DIRTY (SHR) STACK" |
830 | #define MIN_WIDTH sizeof(HDR_STR) | 830 | #define MIN_WIDTH sizeof(HDR_STR) |
831 | const topmem_status_t *s = topmem + G_scroll_ofs; | 831 | const topmem_status_t *s = topmem + G_scroll_ofs; |
832 | char *cp, ch; | ||
832 | 833 | ||
833 | display_topmem_header(scr_width, &lines_rem); | 834 | display_topmem_header(scr_width, &lines_rem); |
835 | |||
834 | strcpy(line_buf, HDR_STR " COMMAND"); | 836 | strcpy(line_buf, HDR_STR " COMMAND"); |
835 | line_buf[11 + sort_field * 6] = "^_"[inverted]; | 837 | /* Mark the ^FIELD^ we sort by */ |
838 | cp = &line_buf[5 + sort_field * 6]; | ||
839 | ch = "^_"[inverted]; | ||
840 | cp[6] = ch; | ||
841 | do *cp++ = ch; while (*cp == ' '); | ||
842 | |||
836 | printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, line_buf); | 843 | printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, line_buf); |
837 | lines_rem--; | 844 | lines_rem--; |
838 | 845 | ||
@@ -1172,10 +1179,8 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
1172 | ntop = 0; | 1179 | ntop = 0; |
1173 | while ((p = procps_scan(p, scan_mask)) != NULL) { | 1180 | while ((p = procps_scan(p, scan_mask)) != NULL) { |
1174 | int n; | 1181 | int n; |
1175 | #if ENABLE_FEATURE_TOPMEM | 1182 | |
1176 | if (scan_mask != TOPMEM_MASK) | 1183 | IF_FEATURE_TOPMEM(if (scan_mask != TOPMEM_MASK)) { |
1177 | #endif | ||
1178 | { | ||
1179 | n = ntop; | 1184 | n = ntop; |
1180 | top = xrealloc_vector(top, 6, ntop++); | 1185 | top = xrealloc_vector(top, 6, ntop++); |
1181 | top[n].pid = p->pid; | 1186 | top[n].pid = p->pid; |
@@ -1215,7 +1220,7 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
1215 | break; | 1220 | break; |
1216 | } | 1221 | } |
1217 | 1222 | ||
1218 | if (scan_mask != TOPMEM_MASK) { | 1223 | IF_FEATURE_TOPMEM(if (scan_mask != TOPMEM_MASK)) { |
1219 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 1224 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
1220 | if (!prev_hist_count) { | 1225 | if (!prev_hist_count) { |
1221 | do_stats(); | 1226 | do_stats(); |
@@ -1229,17 +1234,13 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
1229 | #else | 1234 | #else |
1230 | qsort(top, ntop, sizeof(top_status_t), (void*)(sort_function[0])); | 1235 | qsort(top, ntop, sizeof(top_status_t), (void*)(sort_function[0])); |
1231 | #endif | 1236 | #endif |
1237 | display_process_list(G.lines, col); | ||
1232 | } | 1238 | } |
1233 | #if ENABLE_FEATURE_TOPMEM | 1239 | #if ENABLE_FEATURE_TOPMEM |
1234 | else { /* TOPMEM */ | 1240 | else { /* TOPMEM */ |
1235 | qsort(topmem, ntop, sizeof(topmem_status_t), (void*)topmem_sort); | 1241 | qsort(topmem, ntop, sizeof(topmem_status_t), (void*)topmem_sort); |
1236 | } | ||
1237 | #endif | ||
1238 | if (scan_mask != TOPMEM_MASK) | ||
1239 | display_process_list(G.lines, col); | ||
1240 | #if ENABLE_FEATURE_TOPMEM | ||
1241 | else | ||
1242 | display_topmem_process_list(G.lines, col); | 1242 | display_topmem_process_list(G.lines, col); |
1243 | } | ||
1243 | #endif | 1244 | #endif |
1244 | clearmems(); | 1245 | clearmems(); |
1245 | if (iterations >= 0 && !--iterations) | 1246 | if (iterations >= 0 && !--iterations) |
@@ -1248,7 +1249,7 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
1248 | sleep(interval); | 1249 | sleep(interval); |
1249 | #else | 1250 | #else |
1250 | scan_mask = handle_input(scan_mask, interval); | 1251 | scan_mask = handle_input(scan_mask, interval); |
1251 | #endif /* FEATURE_USE_TERMIOS */ | 1252 | #endif |
1252 | } /* end of "while (not Q)" */ | 1253 | } /* end of "while (not Q)" */ |
1253 | 1254 | ||
1254 | bb_putchar('\n'); | 1255 | bb_putchar('\n'); |