aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-21 23:58:43 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-21 23:58:43 +0200
commitd75295c80bcfa577b124328f09e75ea15facf67f (patch)
tree91997d8bc037ae494576a9366906caf0555663cb /procps
parent69b1cef921ac66e8f792ff52ddb3a5609600a17f (diff)
downloadbusybox-w32-d75295c80bcfa577b124328f09e75ea15facf67f.tar.gz
busybox-w32-d75295c80bcfa577b124328f09e75ea15facf67f.tar.bz2
busybox-w32-d75295c80bcfa577b124328f09e75ea15facf67f.zip
ps: conditionally enable -T on non-DESKTOP build too
function old new delta ps_main 253 274 +21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r--procps/ps.c50
-rw-r--r--procps/top.c6
2 files changed, 28 insertions, 28 deletions
diff --git a/procps/ps.c b/procps/ps.c
index b35b49c04..d86ac6d2f 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -479,7 +479,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv)
479 // Select which columns to display 479 // Select which columns to display
480 /* We allow (and ignore) most of the above. FIXME */ 480 /* We allow (and ignore) most of the above. FIXME */
481 opt_complementary = "o::"; 481 opt_complementary = "o::";
482 opt = getopt32(argv, "Zo:aAdefl" IF_FEATURE_SHOW_THREADS("T"), &opt_o); 482 opt = getopt32(argv, "Zo:aAdefl"IF_FEATURE_SHOW_THREADS("T"), &opt_o);
483 if (opt_o) { 483 if (opt_o) {
484 do { 484 do {
485 parse_o(llist_pop(&opt_o)); 485 parse_o(llist_pop(&opt_o));
@@ -528,56 +528,56 @@ int ps_main(int argc UNUSED_PARAM, char **argv)
528int ps_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 528int ps_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
529int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 529int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
530{ 530{
531 procps_status_t *p = NULL; 531 procps_status_t *p;
532 int len; 532 int len;
533 IF_NOT_SELINUX(const) int use_selinux = 0; 533 int psscan_flags = PSSCAN_PID | PSSCAN_UIDGID
534 IF_SELINUX(int i;) 534 | PSSCAN_STATE | PSSCAN_VSZ | PSSCAN_COMM;
535#if !ENABLE_FEATURE_PS_WIDE 535#if !ENABLE_FEATURE_PS_WIDE
536 enum { terminal_width = 79 }; 536 enum { terminal_width = 79 };
537#else 537#else
538 unsigned terminal_width; 538 unsigned terminal_width;
539 int w_count = 0;
540#endif 539#endif
541 540
542#if ENABLE_FEATURE_PS_WIDE || ENABLE_SELINUX 541#if ENABLE_FEATURE_PS_WIDE || ENABLE_SELINUX
543#if ENABLE_FEATURE_PS_WIDE 542 int opts;
543# if ENABLE_FEATURE_PS_WIDE
544 int w_count = 0;
544 opt_complementary = "-:ww"; 545 opt_complementary = "-:ww";
545 IF_SELINUX(i =) getopt32(argv, IF_SELINUX("Z") "w", &w_count); 546 opts = getopt32(argv, IF_SELINUX("Z")IF_FEATURE_SHOW_THREADS("T")"w", &w_count);
546 /* if w is given once, GNU ps sets the width to 132, 547 /* if w is given once, GNU ps sets the width to 132,
547 * if w is given more than once, it is "unlimited" 548 * if w is given more than once, it is "unlimited"
548 */ 549 */
549 if (w_count) { 550 if (w_count) {
550 terminal_width = (w_count==1) ? 132 : MAX_WIDTH; 551 terminal_width = (w_count == 1) ? 132 : MAX_WIDTH;
551 } else { 552 } else {
552 get_terminal_width_height(0, &terminal_width, NULL); 553 get_terminal_width_height(0, &terminal_width, NULL);
553 /* Go one less... */ 554 /* Go one less... */
554 if (--terminal_width > MAX_WIDTH) 555 if (--terminal_width > MAX_WIDTH)
555 terminal_width = MAX_WIDTH; 556 terminal_width = MAX_WIDTH;
556 } 557 }
557#else /* only ENABLE_SELINUX */ 558# else /* only ENABLE_SELINUX */
558 i = getopt32(argv, "Z"); 559 opts = getopt32(argv, "Z"IF_FEATURE_SHOW_THREADS("T"));
559#endif 560# endif
560#if ENABLE_SELINUX 561# if ENABLE_SELINUX
561 if ((i & 1) && is_selinux_enabled()) 562 if ((opts & 1) && is_selinux_enabled())
562 use_selinux = PSSCAN_CONTEXT; 563 psscan_flags = PSSCAN_PID | PSSCAN_CONTEXT
563#endif 564 | PSSCAN_STATE | PSSCAN_COMM;
565# endif
566# if ENABLE_FEATURE_SHOW_THREADS
567 if (opts & (1 << ENABLE_SELINUX))
568 psscan_flags |= PSSCAN_TASKS;
569# endif
564#endif /* ENABLE_FEATURE_PS_WIDE || ENABLE_SELINUX */ 570#endif /* ENABLE_FEATURE_PS_WIDE || ENABLE_SELINUX */
565 571
566 if (use_selinux) 572 if (psscan_flags & PSSCAN_CONTEXT)
567 puts(" PID CONTEXT STAT COMMAND"); 573 puts(" PID CONTEXT STAT COMMAND");
568 else 574 else
569 puts(" PID USER VSZ STAT COMMAND"); 575 puts(" PID USER VSZ STAT COMMAND");
570 576
571 while ((p = procps_scan(p, 0 577 p = NULL;
572 | PSSCAN_PID 578 while ((p = procps_scan(p, psscan_flags)) != NULL) {
573 | PSSCAN_UIDGID
574 | PSSCAN_STATE
575 | PSSCAN_VSZ
576 | PSSCAN_COMM
577 | use_selinux
578 )) != NULL) {
579#if ENABLE_SELINUX 579#if ENABLE_SELINUX
580 if (use_selinux) { 580 if (psscan_flags & PSSCAN_CONTEXT) {
581 len = printf("%5u %-32.32s %s ", 581 len = printf("%5u %-32.32s %s ",
582 p->pid, 582 p->pid,
583 p->context ? p->context : "unknown", 583 p->context ? p->context : "unknown",
diff --git a/procps/top.c b/procps/top.c
index dbaaca14f..9e8ad1d1f 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -895,7 +895,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
895 int lines_rem; 895 int lines_rem;
896 unsigned interval; 896 unsigned interval;
897 char *str_interval, *str_iterations; 897 char *str_interval, *str_iterations;
898 IF_NOT_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK; 898 unsigned scan_mask = TOP_MASK;
899#if ENABLE_FEATURE_USE_TERMIOS 899#if ENABLE_FEATURE_USE_TERMIOS
900 struct termios new_settings; 900 struct termios new_settings;
901 struct pollfd pfd[1]; 901 struct pollfd pfd[1];
@@ -1080,13 +1080,13 @@ int top_main(int argc UNUSED_PARAM, char **argv)
1080 sort_function[2] = time_sort; 1080 sort_function[2] = time_sort;
1081# endif 1081# endif
1082 } 1082 }
1083#if ENABLE_FEATURE_SHOW_THREADS 1083# if ENABLE_FEATURE_SHOW_THREADS
1084 if (c == 'h' 1084 if (c == 'h'
1085 IF_FEATURE_TOPMEM(&& scan_mask != TOPMEM_MASK) 1085 IF_FEATURE_TOPMEM(&& scan_mask != TOPMEM_MASK)
1086 ) { 1086 ) {
1087 scan_mask ^= PSSCAN_TASKS; 1087 scan_mask ^= PSSCAN_TASKS;
1088 } 1088 }
1089#endif 1089# endif
1090# if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE 1090# if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
1091 if (c == 'p') { 1091 if (c == 'p') {
1092 IF_FEATURE_TOPMEM(scan_mask = TOP_MASK;) 1092 IF_FEATURE_TOPMEM(scan_mask = TOP_MASK;)