Hi,
I've come up with what seems a proper solution to the problem. Please
consider applying this patch to the busybox code.
Regards.
diff -ruN busybox-1.4.2/procps/ps.c busybox-1.4.2-modified/procps/ps.c
--- busybox-1.4.2/procps/ps.c 2007-03-18 17:59:36.000000000 +0100
+++ busybox-1.4.2-modified/procps/ps.c 2007-03-28 16:09:10.000000000 +0200
@@ -115,6 +115,7 @@
static int print_header;
static int ps_flags;
static char *buffer;
+static int buffer_width;
static unsigned terminal_width;
@@ -175,15 +176,15 @@
static void post_process(void)
{
int i;
- int width = 0;
+ buffer_width = 0;
for (i = 0; i < out_cnt; i++) {
ps_flags |= out[i].ps_flags;
if (out[i].header[0]) {
print_header = 1;
}
- width += out[i].width + 1; /* "FIELD " */
+ buffer_width += out[i].width + 1; /* "FIELD " */
}
- buffer = xmalloc(width + 1); /* for trailing \0 */
+ buffer = xmalloc(buffer_width + 1); /* for trailing \0 */
}
static void format_header(void)
@@ -203,7 +204,8 @@
}
strcpy(p, op->header);
}
- printf("%.*s\n", terminal_width, buffer);
+ if (terminal_width < buffer_width) buffer[terminal_width] = 0;
+ printf("%s\n", buffer);
}
static void format_process(const procps_status_t *ps)
@@ -227,7 +229,8 @@
break;
p += sprintf(p, "%*s", len, "");
}
- printf("%.*s\n", terminal_width, buffer);
+ if (terminal_width < buffer_width) buffer[terminal_width] = 0;
+ printf("%s\n", buffer);
}
/* Cannot be const: parse_o() will choke */
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox