diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-09-15 08:33:45 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-09-15 08:33:45 +0000 |
commit | 8efe967018dd79aacfe3ca1e2583f115d744e466 (patch) | |
tree | 7590704be6cf03c87242043f5909e12eb4150356 /procps | |
parent | c4f72d1426e03f046ac54a00d733a4a52c3a5d4b (diff) | |
download | busybox-w32-8efe967018dd79aacfe3ca1e2583f115d744e466.tar.gz busybox-w32-8efe967018dd79aacfe3ca1e2583f115d744e466.tar.bz2 busybox-w32-8efe967018dd79aacfe3ca1e2583f115d744e466.zip |
Be entirely consistant when using ioctl(0, TIOCGWINSZ, &winsize)
to ensure proper fallback behavior on, i.e. serial consoles.
-Erik
Diffstat (limited to 'procps')
-rw-r--r-- | procps/ps.c | 14 | ||||
-rw-r--r-- | procps/top.c | 21 |
2 files changed, 12 insertions, 23 deletions
diff --git a/procps/ps.c b/procps/ps.c index 9dc45d35d..b9d15b861 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -44,12 +44,7 @@ extern int ps_main(int argc, char **argv) | |||
44 | { | 44 | { |
45 | procps_status_t * p; | 45 | procps_status_t * p; |
46 | int i, len; | 46 | int i, len; |
47 | #ifdef CONFIG_FEATURE_AUTOWIDTH | ||
48 | struct winsize win = { 0, 0, 0, 0 }; | ||
49 | int terminal_width = TERMINAL_WIDTH; | 47 | int terminal_width = TERMINAL_WIDTH; |
50 | #else | ||
51 | #define terminal_width TERMINAL_WIDTH | ||
52 | #endif | ||
53 | 48 | ||
54 | #ifdef CONFIG_SELINUX | 49 | #ifdef CONFIG_SELINUX |
55 | int use_selinux = 0; | 50 | int use_selinux = 0; |
@@ -58,12 +53,9 @@ extern int ps_main(int argc, char **argv) | |||
58 | use_selinux = 1; | 53 | use_selinux = 1; |
59 | #endif | 54 | #endif |
60 | 55 | ||
61 | 56 | get_terminal_width_height(0, &terminal_width, NULL); | |
62 | #ifdef CONFIG_FEATURE_AUTOWIDTH | 57 | /* Go one less... */ |
63 | ioctl(fileno(stdout), TIOCGWINSZ, &win); | 58 | terminal_width--; |
64 | if (win.ws_col > 0) | ||
65 | terminal_width = win.ws_col - 1; | ||
66 | #endif | ||
67 | 59 | ||
68 | #ifdef CONFIG_SELINUX | 60 | #ifdef CONFIG_SELINUX |
69 | if(use_selinux) | 61 | if(use_selinux) |
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; |