summaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorDenis Vlasenko2007-07-25 17:27:58 +0000
committerDenis Vlasenko2007-07-25 17:27:58 +0000
commit7ce7594fa31c64f49f9e6730c605879e0f3e7ac8 (patch)
tree0ac98227bffb1102fe92cdac6ea595c7ebb4a24b /procps
parentf4cee7a1746ac048b09ce51538f01d5440a180a3 (diff)
downloadbusybox-7ce7594fa31c64f49f9e6730c605879e0f3e7ac8.zip
busybox-7ce7594fa31c64f49f9e6730c605879e0f3e7ac8.tar.gz
ps: fix non-desktop ps -ww -- thanks rockeychu
Diffstat (limited to 'procps')
-rw-r--r--procps/ps.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/procps/ps.c b/procps/ps.c
index 47e4c61..50b6a6c 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -11,6 +11,9 @@
#include "libbb.h"
+/* Absolute maximum on output line length */
+enum { MAX_WIDTH = 2*1024 };
+
#if ENABLE_DESKTOP
/* Print value to buf, max size+1 chars (including trailing '\0') */
@@ -317,10 +320,11 @@ int ps_main(int argc, char **argv)
/* Was INT_MAX, but some libc's go belly up with printf("%.*s")
* and such large widths */
- terminal_width = 30000;
+ terminal_width = MAX_WIDTH;
if (isatty(1)) {
get_terminal_width_height(1, &terminal_width, NULL);
- terminal_width--;
+ if (--terminal_width > MAX_WIDTH)
+ terminal_width = MAX_WIDTH;
}
format_header();
@@ -358,11 +362,12 @@ int ps_main(int argc, char **argv)
* if w is given more than once, it is "unlimited"
*/
if (w_count) {
- terminal_width = (w_count==1) ? 132 : INT_MAX;
+ terminal_width = (w_count==1) ? 132 : MAX_WIDTH;
} else {
get_terminal_width_height(1, &terminal_width, NULL);
/* Go one less... */
- terminal_width--;
+ if (--terminal_width > MAX_WIDTH)
+ terminal_width = MAX_WIDTH;
}
#else /* only ENABLE_SELINUX */
i = getopt32(argc, argv, "Z");