[BusyBox-cvs] busybox/procps ps.c,1.50,1.51 top.c,1.7,1.8

Erik Andersen andersen at busybox.net
Mon Sep 15 08:33:42 UTC 2003


Update of /var/cvs/busybox/procps
In directory winder:/tmp/cvs-serv10511/procps

Modified Files:
	ps.c top.c 
Log Message:
Be entirely consistant when using ioctl(0, TIOCGWINSZ, &winsize)
to ensure proper fallback behavior on, i.e. serial consoles.
 -Erik


Index: top.c
===================================================================
RCS file: /var/cvs/busybox/procps/top.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- top.c	3 Jul 2003 10:07:03 -0000	1.7
+++ top.c	15 Sep 2003 08:33:39 -0000	1.8
@@ -373,10 +373,11 @@
 			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 @@
 	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 @@
 	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;

Index: ps.c
===================================================================
RCS file: /var/cvs/busybox/procps/ps.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- ps.c	14 Jul 2003 21:21:04 -0000	1.50
+++ ps.c	15 Sep 2003 08:33:39 -0000	1.51
@@ -44,12 +44,7 @@
 {
 	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 @@
 		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)




More information about the busybox-cvs mailing list