>Number: 166364
>Category: bin
>Synopsis: make ps(1) display 8-bit characters as such
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Mar 24 01:00:15 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator: J.R. Oldroyd
>Release: FreeBSD 8.2-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD xx.opal.com 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17
02:41:51 UTC 2011 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
Currently, ps(1) uses strvis(3) to pretty-up all commands and arguments before
they
are displayed. This has the detrimental effect of converting 8-bit characters
in
command names and argument lists to sequences such as "\M-C\M-)" for a simple
"é" (e-acute), etc, thereby making ps' output very awkward for those of us
that work
in languages that use 8-bit characters. These sequences are not
human-readable, nor
is it possible to cut and paste such words back to the command line.
It is unclear why strvis() is used here, but it exists in the ps(1) source from
the
earliest version in svn. If strvis() is no longer needed here, it should be
removed,
or at the least replaced with code that removes "dangerous" characters
(whatever they
may be) but which leaves 8-bit alphabetics alone.
The attached diff removes the four strvis() calls and replaces them with
strcpy().
A cleaner solution would rework the associated code to no longer need the copy
at
all, by using the "src" variable in place of the "dst" one in the code following
and so eliminating the need for the "dst" variable.
For comparison, procstat(1) does not do any pretty-printing of command names or
arguments in this way.
>How-To-Repeat:
1. Run any command that has any 8-bit character in its name or any argument.
2. Run "ps ax" while that command is running and examine the ps output.
>Fix:
--- fmt.oc 2011-02-22 12:25:38.000000000 -0500
+++ fmt.c 2012-03-23 20:07:23.000000000 -0400
@@ -47,7 +47,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <vis.h>
#include "ps.h"
@@ -82,8 +81,7 @@
if (*src == '\0')
continue;
len = (buf_size - 1 - (dst - buf)) / 4;
- strvisx(dst, src, strlen(src) < len ? strlen(src) : len,
- VIS_NL | VIS_CSTYLE);
+ strcpy(dst, src);
while (*dst != '\0')
dst++;
if ((buf_size - 1 - (dst - buf)) / 4 > 0)
--- print.oc 2011-02-22 12:25:38.000000000 -0500
+++ print.c 2012-03-23 20:07:57.000000000 -0400
@@ -58,7 +58,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <vis.h>
#include "ps.h"
@@ -101,7 +100,7 @@
v = ve->var;
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
errx(1, "malloc failed");
- strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
+ strcpy(vis_args, k->ki_args);
if (STAILQ_NEXT(ve, next_ve) == NULL) {
/* last field */
if (termwidth == UNLIMITED) {
@@ -141,7 +140,7 @@
}
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
errx(1, "malloc failed");
- strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
+ strcpy(vis_args, k->ki_args);
if (STAILQ_NEXT(ve, next_ve) == NULL) {
/* last field */
@@ -150,8 +149,7 @@
if ((vis_env = malloc(strlen(k->ki_env) * 4 + 1))
== NULL)
errx(1, "malloc failed");
- strvis(vis_env, k->ki_env,
- VIS_TAB | VIS_NL | VIS_NOSLASH);
+ strcpy(vis_env, k->ki_env);
} else
vis_env = NULL;
>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"