diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-25 17:27:58 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-25 17:27:58 +0000 |
commit | 7ce7594fa31c64f49f9e6730c605879e0f3e7ac8 (patch) | |
tree | 0ac98227bffb1102fe92cdac6ea595c7ebb4a24b /procps | |
parent | f4cee7a1746ac048b09ce51538f01d5440a180a3 (diff) | |
download | busybox-w32-7ce7594fa31c64f49f9e6730c605879e0f3e7ac8.tar.gz busybox-w32-7ce7594fa31c64f49f9e6730c605879e0f3e7ac8.tar.bz2 busybox-w32-7ce7594fa31c64f49f9e6730c605879e0f3e7ac8.zip |
ps: fix non-desktop ps -ww -- thanks rockeychu
Diffstat (limited to 'procps')
-rw-r--r-- | procps/ps.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/procps/ps.c b/procps/ps.c index 47e4c6111..50b6a6c94 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -11,6 +11,9 @@ | |||
11 | 11 | ||
12 | #include "libbb.h" | 12 | #include "libbb.h" |
13 | 13 | ||
14 | /* Absolute maximum on output line length */ | ||
15 | enum { MAX_WIDTH = 2*1024 }; | ||
16 | |||
14 | #if ENABLE_DESKTOP | 17 | #if ENABLE_DESKTOP |
15 | 18 | ||
16 | /* Print value to buf, max size+1 chars (including trailing '\0') */ | 19 | /* Print value to buf, max size+1 chars (including trailing '\0') */ |
@@ -317,10 +320,11 @@ int ps_main(int argc, char **argv) | |||
317 | 320 | ||
318 | /* Was INT_MAX, but some libc's go belly up with printf("%.*s") | 321 | /* Was INT_MAX, but some libc's go belly up with printf("%.*s") |
319 | * and such large widths */ | 322 | * and such large widths */ |
320 | terminal_width = 30000; | 323 | terminal_width = MAX_WIDTH; |
321 | if (isatty(1)) { | 324 | if (isatty(1)) { |
322 | get_terminal_width_height(1, &terminal_width, NULL); | 325 | get_terminal_width_height(1, &terminal_width, NULL); |
323 | terminal_width--; | 326 | if (--terminal_width > MAX_WIDTH) |
327 | terminal_width = MAX_WIDTH; | ||
324 | } | 328 | } |
325 | format_header(); | 329 | format_header(); |
326 | 330 | ||
@@ -358,11 +362,12 @@ int ps_main(int argc, char **argv) | |||
358 | * if w is given more than once, it is "unlimited" | 362 | * if w is given more than once, it is "unlimited" |
359 | */ | 363 | */ |
360 | if (w_count) { | 364 | if (w_count) { |
361 | terminal_width = (w_count==1) ? 132 : INT_MAX; | 365 | terminal_width = (w_count==1) ? 132 : MAX_WIDTH; |
362 | } else { | 366 | } else { |
363 | get_terminal_width_height(1, &terminal_width, NULL); | 367 | get_terminal_width_height(1, &terminal_width, NULL); |
364 | /* Go one less... */ | 368 | /* Go one less... */ |
365 | terminal_width--; | 369 | if (--terminal_width > MAX_WIDTH) |
370 | terminal_width = MAX_WIDTH; | ||
366 | } | 371 | } |
367 | #else /* only ENABLE_SELINUX */ | 372 | #else /* only ENABLE_SELINUX */ |
368 | i = getopt32(argc, argv, "Z"); | 373 | i = getopt32(argc, argv, "Z"); |