[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: show thread as process
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2009-09-21 21:58:05
Message-ID: 200909212358.05571.vda.linux () googlemail ! com
[Download RAW message or body]
On Monday 21 September 2009 12:52, Fabian Meier wrote:
> Hi,
>
> Thanks, I just tested the patch. It works with CONFIG_DESKTOP. So I
> will have to switch to this option. The binary increases by 5k.
> Is there also noticeable memory & performance loss by switching to
> CONFIG_DESKTOP? The system is a ppc855 60Mhz and 64Mb ram.
> Maybe it is better for me to just patch the procps_scan mask (in bb 1.16.0) with
>
> while ((p = procps_scan(p, 0
> | PSSCAN_PID
> | PSSCAN_UIDGID
> | PSSCAN_STATE
> | PSSCAN_VSZ
> | PSSCAN_COMM
> | use_selinux
> #if ENABLE_FEATURE_SHOW_THREADS
> | PSSCAN_TASKS
> #endif
> )) != NULL) {
>
> I will go this way I guess.
Or you may do it properly: enable -T option.
See attached patch.
> Besides, there is a (config) bug in your patch:
>
> CC procps/top.o
> procps/top.c: In function 'top_main':
> procps/top.c:1087: error: assignment of read-only variable 'scan_mask'
> make[1]: *** [procps/top.o] Error 1
> make: *** [procps] Error 2
>
> [ ] Topmem command ('s' key)
>
> IF_NOT_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK;
Fixed, thanks.
--
vda
["5.patch" (text/x-diff)]
diff -d -urpN busybox.4/procps/ps.c busybox.5/procps/ps.c
--- busybox.4/procps/ps.c 2009-09-21 01:21:29.000000000 +0200
+++ busybox.5/procps/ps.c 2009-09-21 23:56:14.000000000 +0200
@@ -479,7 +479,7 @@ int ps_main(int argc UNUSED_PARAM, char
// Select which columns to display
/* We allow (and ignore) most of the above. FIXME */
opt_complementary = "o::";
- opt = getopt32(argv, "Zo:aAdefl" IF_FEATURE_SHOW_THREADS("T"), &opt_o);
+ opt = getopt32(argv, "Zo:aAdefl"IF_FEATURE_SHOW_THREADS("T"), &opt_o);
if (opt_o) {
do {
parse_o(llist_pop(&opt_o));
@@ -528,56 +528,56 @@ int ps_main(int argc UNUSED_PARAM, char
int ps_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
- procps_status_t *p = NULL;
+ procps_status_t *p;
int len;
- IF_NOT_SELINUX(const) int use_selinux = 0;
- IF_SELINUX(int i;)
+ int psscan_flags = PSSCAN_PID | PSSCAN_UIDGID
+ | PSSCAN_STATE | PSSCAN_VSZ | PSSCAN_COMM;
#if !ENABLE_FEATURE_PS_WIDE
enum { terminal_width = 79 };
#else
unsigned terminal_width;
- int w_count = 0;
#endif
#if ENABLE_FEATURE_PS_WIDE || ENABLE_SELINUX
-#if ENABLE_FEATURE_PS_WIDE
+ int opts;
+# if ENABLE_FEATURE_PS_WIDE
+ int w_count = 0;
opt_complementary = "-:ww";
- IF_SELINUX(i =) getopt32(argv, IF_SELINUX("Z") "w", &w_count);
+ opts = getopt32(argv, IF_SELINUX("Z")IF_FEATURE_SHOW_THREADS("T")"w", &w_count);
/* if w is given once, GNU ps sets the width to 132,
* if w is given more than once, it is "unlimited"
*/
if (w_count) {
- terminal_width = (w_count==1) ? 132 : MAX_WIDTH;
+ terminal_width = (w_count == 1) ? 132 : MAX_WIDTH;
} else {
get_terminal_width_height(0, &terminal_width, NULL);
/* Go one less... */
if (--terminal_width > MAX_WIDTH)
terminal_width = MAX_WIDTH;
}
-#else /* only ENABLE_SELINUX */
- i = getopt32(argv, "Z");
-#endif
-#if ENABLE_SELINUX
- if ((i & 1) && is_selinux_enabled())
- use_selinux = PSSCAN_CONTEXT;
-#endif
+# else /* only ENABLE_SELINUX */
+ opts = getopt32(argv, "Z"IF_FEATURE_SHOW_THREADS("T"));
+# endif
+# if ENABLE_SELINUX
+ if ((opts & 1) && is_selinux_enabled())
+ psscan_flags = PSSCAN_PID | PSSCAN_CONTEXT
+ | PSSCAN_STATE | PSSCAN_COMM;
+# endif
+# if ENABLE_FEATURE_SHOW_THREADS
+ if (opts & (1 << ENABLE_SELINUX))
+ psscan_flags |= PSSCAN_TASKS;
+# endif
#endif /* ENABLE_FEATURE_PS_WIDE || ENABLE_SELINUX */
- if (use_selinux)
+ if (psscan_flags & PSSCAN_CONTEXT)
puts(" PID CONTEXT STAT COMMAND");
else
puts(" PID USER VSZ STAT COMMAND");
- while ((p = procps_scan(p, 0
- | PSSCAN_PID
- | PSSCAN_UIDGID
- | PSSCAN_STATE
- | PSSCAN_VSZ
- | PSSCAN_COMM
- | use_selinux
- )) != NULL) {
+ p = NULL;
+ while ((p = procps_scan(p, psscan_flags)) != NULL) {
#if ENABLE_SELINUX
- if (use_selinux) {
+ if (psscan_flags & PSSCAN_CONTEXT) {
len = printf("%5u %-32.32s %s ",
p->pid,
p->context ? p->context : "unknown",
diff -d -urpN busybox.4/procps/top.c busybox.5/procps/top.c
--- busybox.4/procps/top.c 2009-09-21 01:21:29.000000000 +0200
+++ busybox.5/procps/top.c 2009-09-21 23:56:14.000000000 +0200
@@ -895,7 +895,7 @@ int top_main(int argc UNUSED_PARAM, char
int lines_rem;
unsigned interval;
char *str_interval, *str_iterations;
- IF_NOT_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK;
+ unsigned scan_mask = TOP_MASK;
#if ENABLE_FEATURE_USE_TERMIOS
struct termios new_settings;
struct pollfd pfd[1];
@@ -1080,13 +1080,13 @@ int top_main(int argc UNUSED_PARAM, char
sort_function[2] = time_sort;
# endif
}
-#if ENABLE_FEATURE_SHOW_THREADS
+# if ENABLE_FEATURE_SHOW_THREADS
if (c == 'h'
IF_FEATURE_TOPMEM(&& scan_mask != TOPMEM_MASK)
) {
scan_mask ^= PSSCAN_TASKS;
}
-#endif
+# endif
# if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
if (c == 'p') {
IF_FEATURE_TOPMEM(scan_mask = TOP_MASK;)
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic