diff options
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> | 2019-03-26 13:10:21 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-04 14:14:24 +0200 |
commit | 2b6282117f026cfa2a3e7efee7caa054b6265264 (patch) | |
tree | 1127f82c0841cf66600501362f94f0e9d38b8883 | |
parent | a3ce161363380899ae45716c70714cfcc93a7755 (diff) | |
download | busybox-w32-2b6282117f026cfa2a3e7efee7caa054b6265264.tar.gz busybox-w32-2b6282117f026cfa2a3e7efee7caa054b6265264.tar.bz2 busybox-w32-2b6282117f026cfa2a3e7efee7caa054b6265264.zip |
top: provide cmdline argument '-H' to enable thread scanning by default
In particular useful when you want to evaluate the threads in batch mode:
top -Hbn1
function old new delta
top_main 928 941 +13
packed_usage 33317 33319 +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 15/0) Total: 15 bytes
Signed-off-by: Philippe Belet <philippe.belet@nokia.com>
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | procps/top.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/procps/top.c b/procps/top.c index 625409755..89f9d23f4 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -222,8 +222,9 @@ enum { | |||
222 | OPT_d = (1 << 0), | 222 | OPT_d = (1 << 0), |
223 | OPT_n = (1 << 1), | 223 | OPT_n = (1 << 1), |
224 | OPT_b = (1 << 2), | 224 | OPT_b = (1 << 2), |
225 | OPT_m = (1 << 3), | 225 | OPT_H = (1 << 3), |
226 | OPT_EOF = (1 << 4), /* pseudo: "we saw EOF in stdin" */ | 226 | OPT_m = (1 << 4), |
227 | OPT_EOF = (1 << 5), /* pseudo: "we saw EOF in stdin" */ | ||
227 | }; | 228 | }; |
228 | #define OPT_BATCH_MODE (option_mask32 & OPT_b) | 229 | #define OPT_BATCH_MODE (option_mask32 & OPT_b) |
229 | 230 | ||
@@ -1043,7 +1044,8 @@ static unsigned handle_input(unsigned scan_mask, duration_t interval) | |||
1043 | //usage:# define IF_SHOW_THREADS_OR_TOP_SMP(...) | 1044 | //usage:# define IF_SHOW_THREADS_OR_TOP_SMP(...) |
1044 | //usage:#endif | 1045 | //usage:#endif |
1045 | //usage:#define top_trivial_usage | 1046 | //usage:#define top_trivial_usage |
1046 | //usage: "[-b"IF_FEATURE_TOPMEM("m")"] [-n COUNT] [-d SECONDS]" | 1047 | //usage: "[-b"IF_FEATURE_TOPMEM("m")IF_FEATURE_SHOW_THREADS("H")"]" |
1048 | //usage: " [-n COUNT] [-d SECONDS]" | ||
1047 | //usage:#define top_full_usage "\n\n" | 1049 | //usage:#define top_full_usage "\n\n" |
1048 | //usage: "Provide a view of process activity in real time." | 1050 | //usage: "Provide a view of process activity in real time." |
1049 | //usage: "\n""Read the status of all processes from /proc each SECONDS" | 1051 | //usage: "\n""Read the status of all processes from /proc each SECONDS" |
@@ -1076,6 +1078,9 @@ static unsigned handle_input(unsigned scan_mask, duration_t interval) | |||
1076 | //usage: IF_FEATURE_TOPMEM( | 1078 | //usage: IF_FEATURE_TOPMEM( |
1077 | //usage: "\n"" -m Same as 's' key" | 1079 | //usage: "\n"" -m Same as 's' key" |
1078 | //usage: ) | 1080 | //usage: ) |
1081 | //usage: IF_FEATURE_SHOW_THREADS( | ||
1082 | //usage: "\n"" -H Show threads" | ||
1083 | //usage: ) | ||
1079 | 1084 | ||
1080 | /* Interactive testing: | 1085 | /* Interactive testing: |
1081 | * echo sss | ./busybox top | 1086 | * echo sss | ./busybox top |
@@ -1110,7 +1115,8 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
1110 | 1115 | ||
1111 | /* all args are options; -n NUM */ | 1116 | /* all args are options; -n NUM */ |
1112 | make_all_argv_opts(argv); /* options can be specified w/o dash */ | 1117 | make_all_argv_opts(argv); /* options can be specified w/o dash */ |
1113 | col = getopt32(argv, "d:n:b"IF_FEATURE_TOPMEM("m"), &str_interval, &str_iterations); | 1118 | col = getopt32(argv, "d:n:bHm", &str_interval, &str_iterations); |
1119 | /* NB: -m and -H are accepted even if not configured */ | ||
1114 | #if ENABLE_FEATURE_TOPMEM | 1120 | #if ENABLE_FEATURE_TOPMEM |
1115 | if (col & OPT_m) /* -m (busybox specific) */ | 1121 | if (col & OPT_m) /* -m (busybox specific) */ |
1116 | scan_mask = TOPMEM_MASK; | 1122 | scan_mask = TOPMEM_MASK; |
@@ -1129,6 +1135,11 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
1129 | str_iterations++; | 1135 | str_iterations++; |
1130 | iterations = xatou(str_iterations); | 1136 | iterations = xatou(str_iterations); |
1131 | } | 1137 | } |
1138 | #if ENABLE_FEATURE_SHOW_THREADS | ||
1139 | if (col & OPT_H) { | ||
1140 | scan_mask |= PSSCAN_TASKS; | ||
1141 | } | ||
1142 | #endif | ||
1132 | 1143 | ||
1133 | /* change to /proc */ | 1144 | /* change to /proc */ |
1134 | xchdir("/proc"); | 1145 | xchdir("/proc"); |