aboutsummaryrefslogtreecommitdiff
path: root/procps/top.c
diff options
context:
space:
mode:
Diffstat (limited to 'procps/top.c')
-rw-r--r--procps/top.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/procps/top.c b/procps/top.c
index 2e1bd3286..cee1b52c1 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -373,10 +373,11 @@ static void display_status(int count, int col)
373 sprintf(rss_str_buf, "%6ldM", s->rss/1024); 373 sprintf(rss_str_buf, "%6ldM", s->rss/1024);
374 else 374 else
375 sprintf(rss_str_buf, "%7ld", s->rss); 375 sprintf(rss_str_buf, "%7ld", s->rss);
376 printf(
376#ifdef FEATURE_CPU_USAGE_PERCENTAGE 377#ifdef FEATURE_CPU_USAGE_PERCENTAGE
377 printf("%5d %-8s %s %s %5d %2d.%d %2u.%u ", 378 "%5d %-8s %s %s %5d %2d.%d %2u.%u ",
378#else 379#else
379 printf("%5d %-8s %s %s %5d %2u.%u ", 380 "%5d %-8s %s %s %5d %2u.%u ",
380#endif 381#endif
381 s->pid, s->user, s->state, rss_str_buf, s->ppid, 382 s->pid, s->user, s->state, rss_str_buf, s->ppid,
382#ifdef FEATURE_CPU_USAGE_PERCENTAGE 383#ifdef FEATURE_CPU_USAGE_PERCENTAGE
@@ -432,9 +433,6 @@ int top_main(int argc, char **argv)
432 fd_set readfds; 433 fd_set readfds;
433 unsigned char c; 434 unsigned char c;
434 struct sigaction sa; 435 struct sigaction sa;
435#if defined CONFIG_FEATURE_AUTOWIDTH
436 struct winsize win = { 0, 0, 0, 0 };
437#endif
438#endif /* CONFIG_FEATURE_USE_TERMIOS */ 436#endif /* CONFIG_FEATURE_USE_TERMIOS */
439 437
440 /* Default update rate is 5 seconds */ 438 /* Default update rate is 5 seconds */
@@ -478,17 +476,16 @@ int top_main(int argc, char **argv)
478 sigaction (SIGINT, &sa, (struct sigaction *) 0); 476 sigaction (SIGINT, &sa, (struct sigaction *) 0);
479 tcsetattr(0, TCSANOW, (void *) &new_settings); 477 tcsetattr(0, TCSANOW, (void *) &new_settings);
480 atexit(reset_term); 478 atexit(reset_term);
481#if defined CONFIG_FEATURE_AUTOWIDTH 479
482 ioctl(0, TIOCGWINSZ, &win); 480 get_terminal_width_height(0, &col, &lines);
483 if (win.ws_row > 4) { 481 if (lines > 4) {
484 lines = win.ws_row - 5; 482 lines -= 5;
485#ifdef FEATURE_CPU_USAGE_PERCENTAGE 483#ifdef FEATURE_CPU_USAGE_PERCENTAGE
486 col = win.ws_col - 80 + 35 - 6; 484 col = col - 80 + 35 - 6;
487#else 485#else
488 col = win.ws_col - 80 + 35; 486 col = col - 80 + 35;
489#endif 487#endif
490 } 488 }
491#endif
492#endif /* CONFIG_FEATURE_USE_TERMIOS */ 489#endif /* CONFIG_FEATURE_USE_TERMIOS */
493#ifdef FEATURE_CPU_USAGE_PERCENTAGE 490#ifdef FEATURE_CPU_USAGE_PERCENTAGE
494 sort_function[0] = pcpu_sort; 491 sort_function[0] = pcpu_sort;