aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-09-15 08:33:45 +0000
committerEric Andersen <andersen@codepoet.org>2003-09-15 08:33:45 +0000
commit8efe967018dd79aacfe3ca1e2583f115d744e466 (patch)
tree7590704be6cf03c87242043f5909e12eb4150356 /procps
parentc4f72d1426e03f046ac54a00d733a4a52c3a5d4b (diff)
downloadbusybox-8efe967018dd79aacfe3ca1e2583f115d744e466.tar.gz
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.c14
-rw-r--r--procps/top.c21
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)
{
procps_status_t * p;
int i, len;
-#ifdef CONFIG_FEATURE_AUTOWIDTH
- struct winsize win = { 0, 0, 0, 0 };
int terminal_width = TERMINAL_WIDTH;
-#else
-#define terminal_width TERMINAL_WIDTH
-#endif
#ifdef CONFIG_SELINUX
int use_selinux = 0;
@@ -58,12 +53,9 @@ extern int ps_main(int argc, char **argv)
use_selinux = 1;
#endif
-
-#ifdef CONFIG_FEATURE_AUTOWIDTH
- ioctl(fileno(stdout), TIOCGWINSZ, &win);
- if (win.ws_col > 0)
- terminal_width = win.ws_col - 1;
-#endif
+ get_terminal_width_height(0, &terminal_width, NULL);
+ /* Go one less... */
+ terminal_width--;
#ifdef CONFIG_SELINUX
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)
sprintf(rss_str_buf, "%6ldM", s->rss/1024);
else
sprintf(rss_str_buf, "%7ld", s->rss);
+ printf(
#ifdef FEATURE_CPU_USAGE_PERCENTAGE
- printf("%5d %-8s %s %s %5d %2d.%d %2u.%u ",
+ "%5d %-8s %s %s %5d %2d.%d %2u.%u ",
#else
- printf("%5d %-8s %s %s %5d %2u.%u ",
+ "%5d %-8s %s %s %5d %2u.%u ",
#endif
s->pid, s->user, s->state, rss_str_buf, s->ppid,
#ifdef FEATURE_CPU_USAGE_PERCENTAGE
@@ -432,9 +433,6 @@ int top_main(int argc, char **argv)
fd_set readfds;
unsigned char c;
struct sigaction sa;
-#if defined CONFIG_FEATURE_AUTOWIDTH
- struct winsize win = { 0, 0, 0, 0 };
-#endif
#endif /* CONFIG_FEATURE_USE_TERMIOS */
/* Default update rate is 5 seconds */
@@ -478,17 +476,16 @@ int top_main(int argc, char **argv)
sigaction (SIGINT, &sa, (struct sigaction *) 0);
tcsetattr(0, TCSANOW, (void *) &new_settings);
atexit(reset_term);
-#if defined CONFIG_FEATURE_AUTOWIDTH
- ioctl(0, TIOCGWINSZ, &win);
- if (win.ws_row > 4) {
- lines = win.ws_row - 5;
+
+ get_terminal_width_height(0, &col, &lines);
+ if (lines > 4) {
+ lines -= 5;
#ifdef FEATURE_CPU_USAGE_PERCENTAGE
- col = win.ws_col - 80 + 35 - 6;
+ col = col - 80 + 35 - 6;
#else
- col = win.ws_col - 80 + 35;
+ col = col - 80 + 35;
#endif
}
-#endif
#endif /* CONFIG_FEATURE_USE_TERMIOS */
#ifdef FEATURE_CPU_USAGE_PERCENTAGE
sort_function[0] = pcpu_sort;