aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--procps/top.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/procps/top.c b/procps/top.c
index 69f63d08b..a9580962a 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -85,6 +85,12 @@ struct globals {
85#endif 85#endif
86}; 86};
87#define G (*(struct globals*)&bb_common_bufsiz1) 87#define G (*(struct globals*)&bb_common_bufsiz1)
88#define INIT_G() \
89 do { \
90 struct G_sizecheck { \
91 char G_sizecheck[sizeof(G) > COMMON_BUFSIZE ? -1 : 1]; \
92 }; \
93 } while (0)
88#define top (G.top ) 94#define top (G.top )
89#define ntop (G.ntop ) 95#define ntop (G.ntop )
90#define sort_field (G.sort_field ) 96#define sort_field (G.sort_field )
@@ -512,20 +518,9 @@ static void sig_catcher(int sig ATTRIBUTE_UNUSED)
512} 518}
513#endif /* FEATURE_USE_TERMIOS */ 519#endif /* FEATURE_USE_TERMIOS */
514 520
515 521/*
516 522 * TOPMEM support
517 523 */
518
519
520
521
522
523
524
525
526
527
528
529 524
530typedef unsigned long mem_t; 525typedef unsigned long mem_t;
531 526
@@ -766,20 +761,9 @@ void display_topmem_process_list(int count, int scr_width);
766int topmem_sort(char *a, char *b); 761int topmem_sort(char *a, char *b);
767#endif /* TOPMEM */ 762#endif /* TOPMEM */
768 763
769 764/*
770 765 * end TOPMEM support
771 766 */
772
773
774
775
776
777
778
779
780
781
782
783 767
784enum { 768enum {
785 TOP_MASK = 0 769 TOP_MASK = 0
@@ -802,7 +786,7 @@ int top_main(int argc, char **argv)
802{ 786{
803 int count, lines, col; 787 int count, lines, col;
804 unsigned interval; 788 unsigned interval;
805 int iterations = 0; /* infinite */ 789 int iterations;
806 char *sinterval, *siterations; 790 char *sinterval, *siterations;
807 SKIP_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK; 791 SKIP_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK;
808#if ENABLE_FEATURE_USE_TERMIOS 792#if ENABLE_FEATURE_USE_TERMIOS
@@ -814,7 +798,10 @@ int top_main(int argc, char **argv)
814 pfd[0].events = POLLIN; 798 pfd[0].events = POLLIN;
815#endif /* FEATURE_USE_TERMIOS */ 799#endif /* FEATURE_USE_TERMIOS */
816 800
801 INIT_G();
802
817 interval = 5; /* default update rate is 5 seconds */ 803 interval = 5; /* default update rate is 5 seconds */
804 iterations = 0; /* infinite */
818 805
819 /* do normal option parsing */ 806 /* do normal option parsing */
820 opt_complementary = "-"; 807 opt_complementary = "-";
@@ -852,8 +839,7 @@ int top_main(int argc, char **argv)
852 while (1) { 839 while (1) {
853 procps_status_t *p = NULL; 840 procps_status_t *p = NULL;
854 841
855 /* Default */ 842 lines = 24; /* default */
856 lines = 24;
857 col = 79; 843 col = 79;
858#if ENABLE_FEATURE_USE_TERMIOS 844#if ENABLE_FEATURE_USE_TERMIOS
859 get_terminal_width_height(0, &col, &lines); 845 get_terminal_width_height(0, &col, &lines);