diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-19 22:29:42 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-19 22:29:42 +0200 |
commit | b410d4ada73e9ebb30b2b50266a13c30479f5f21 (patch) | |
tree | 0d842b9c0885d1cf06fa6aa67a720b31b89cca55 /procps/top.c | |
parent | f00cfdfae53d8ef623238ecb1001969b5f649cbd (diff) | |
download | busybox-w32-b410d4ada73e9ebb30b2b50266a13c30479f5f21.tar.gz busybox-w32-b410d4ada73e9ebb30b2b50266a13c30479f5f21.tar.bz2 busybox-w32-b410d4ada73e9ebb30b2b50266a13c30479f5f21.zip |
ps,top: add an option to show threads. +260 bytes of code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps/top.c')
-rw-r--r-- | procps/top.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/procps/top.c b/procps/top.c index a1ad7881e..dbaaca14f 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -976,7 +976,10 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
976 | /* read process IDs & status for all the processes */ | 976 | /* read process IDs & status for all the processes */ |
977 | while ((p = procps_scan(p, scan_mask)) != NULL) { | 977 | while ((p = procps_scan(p, scan_mask)) != NULL) { |
978 | int n; | 978 | int n; |
979 | if (scan_mask == TOP_MASK) { | 979 | #if ENABLE_FEATURE_TOPMEM |
980 | if (scan_mask != TOPMEM_MASK) | ||
981 | #endif | ||
982 | { | ||
980 | n = ntop; | 983 | n = ntop; |
981 | top = xrealloc_vector(top, 6, ntop++); | 984 | top = xrealloc_vector(top, 6, ntop++); |
982 | top[n].pid = p->pid; | 985 | top[n].pid = p->pid; |
@@ -991,8 +994,9 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
991 | #if ENABLE_FEATURE_TOP_SMP_PROCESS | 994 | #if ENABLE_FEATURE_TOP_SMP_PROCESS |
992 | top[n].last_seen_on_cpu = p->last_seen_on_cpu; | 995 | top[n].last_seen_on_cpu = p->last_seen_on_cpu; |
993 | #endif | 996 | #endif |
994 | } else { /* TOPMEM */ | 997 | } |
995 | #if ENABLE_FEATURE_TOPMEM | 998 | #if ENABLE_FEATURE_TOPMEM |
999 | else { /* TOPMEM */ | ||
996 | if (!(p->mapped_ro | p->mapped_rw)) | 1000 | if (!(p->mapped_ro | p->mapped_rw)) |
997 | continue; /* kernel threads are ignored */ | 1001 | continue; /* kernel threads are ignored */ |
998 | n = ntop; | 1002 | n = ntop; |
@@ -1007,15 +1011,15 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
1007 | topmem[n].dirty = p->private_dirty + p->shared_dirty; | 1011 | topmem[n].dirty = p->private_dirty + p->shared_dirty; |
1008 | topmem[n].dirty_sh = p->shared_dirty; | 1012 | topmem[n].dirty_sh = p->shared_dirty; |
1009 | topmem[n].stack = p->stack; | 1013 | topmem[n].stack = p->stack; |
1010 | #endif | ||
1011 | } | 1014 | } |
1015 | #endif | ||
1012 | } /* end of "while we read /proc" */ | 1016 | } /* end of "while we read /proc" */ |
1013 | if (ntop == 0) { | 1017 | if (ntop == 0) { |
1014 | bb_error_msg("no process info in /proc"); | 1018 | bb_error_msg("no process info in /proc"); |
1015 | break; | 1019 | break; |
1016 | } | 1020 | } |
1017 | 1021 | ||
1018 | if (scan_mask == TOP_MASK) { | 1022 | if (scan_mask != TOPMEM_MASK) { |
1019 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 1023 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
1020 | if (!prev_hist_count) { | 1024 | if (!prev_hist_count) { |
1021 | do_stats(); | 1025 | do_stats(); |
@@ -1039,7 +1043,7 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
1039 | if (OPT_BATCH_MODE) { | 1043 | if (OPT_BATCH_MODE) { |
1040 | lines_rem = INT_MAX; | 1044 | lines_rem = INT_MAX; |
1041 | } | 1045 | } |
1042 | if (scan_mask == TOP_MASK) | 1046 | if (scan_mask != TOPMEM_MASK) |
1043 | display_process_list(lines_rem, col); | 1047 | display_process_list(lines_rem, col); |
1044 | #if ENABLE_FEATURE_TOPMEM | 1048 | #if ENABLE_FEATURE_TOPMEM |
1045 | else | 1049 | else |
@@ -1076,6 +1080,13 @@ int top_main(int argc UNUSED_PARAM, char **argv) | |||
1076 | sort_function[2] = time_sort; | 1080 | sort_function[2] = time_sort; |
1077 | # endif | 1081 | # endif |
1078 | } | 1082 | } |
1083 | #if ENABLE_FEATURE_SHOW_THREADS | ||
1084 | if (c == 'h' | ||
1085 | IF_FEATURE_TOPMEM(&& scan_mask != TOPMEM_MASK) | ||
1086 | ) { | ||
1087 | scan_mask ^= PSSCAN_TASKS; | ||
1088 | } | ||
1089 | #endif | ||
1079 | # if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 1090 | # if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
1080 | if (c == 'p') { | 1091 | if (c == 'p') { |
1081 | IF_FEATURE_TOPMEM(scan_mask = TOP_MASK;) | 1092 | IF_FEATURE_TOPMEM(scan_mask = TOP_MASK;) |