(Sorry for possible duplicate, the smarthost in USU seems to have marked my original message as SPAM or is just broken. I think I will eventially have to move to some other E-Mail address, not related with USU).
Hello, psmisc-21.6 has several issues in the pstree program: 1) In non-ISO-8859-1 8-bit locales on Linux console, pstree sends the \033(0 escape sequence to the terminal. This means "Use ISO-8859-1 translation table" and therefore breaks the display of all national characters after running pstree. (echo -e '\033(K' is the fix). 2) http://sourceforge.net/tracker/index.php?func=detail&aid=1195650&group_id=15273& atid=115273 Issue (1) is critical, since it makes pstree completely unusable on Linux console in all non-ISO-8859-1 8-bit locales. Issue (2) is also important, since it can turn the terminal session into garbage in any locale (but, as opposed to (1), it is triggered rarely). I have not noticed (1) for a long time because I always start KDM and almost never work in the linux console. My fault. One possible solution is to put a warning in the description of pstree in the LFS book, i.e. "don't use this program on linux console in non-ISO-8859-1 locales - it will break the display of national characters". Another solution is to patch pstree. I have attached two patches to psmisc, please choose one of them or both. The -1a patch just disables the use of VT100 line drawing characters by default and thus avoids these two bugs and some others. The -1b patch attempts to fix those two bugs, but I cannot call the fix 100% correct for xterm (it relies upon the undocumented fact that xterm ignores the "\033(K" sequence). The -1a patch is IMHO a safer solution. Please choose which of the solutions should go into LFS-6.1. -- Alexander E. Patrakov
Submitted by: Alexander E. Patrakov Date: 2005-06-05 Initial Package Version: 21.6 Upstream Status: Not Submitted - Hack Origin: Alexander E. Patrakov Description: This patch disables the use of VT100 line drwaing characters by default in pstree. They are still accessible by runnung pstree -G. Rationale: Use of VT100 line drawing characters is the origin of at least two important bugs: 1) In non-ISO-8859-1 8-bit locales on Linux console, pstree sends the \033(0 escape sequence to the terminal. This means "Use ISO-8859-1 translation table" and therefore breaks the display of all national characters after running pstree. (echo -e '\033(K' is the fix). 2) pstree may break line without turning off ACS mode. If this happens in the last line of output, the subsequent bash prompt and everything else is turned into meaningless line-drawing characters. Example: http://sourceforge.net/tracker/index.php?func=detail&aid=1195650&group_id=15273&atid=115273 There are other bugs, e. g. misaligning of line-drawing characters in Konsole and cutting the line at less than 80 columns, that are also avoided by default due to non-use of VT100 line drawing characters. --- psmisc-21.6/src/pstree.c 2005-06-05 10:43:16.000000000 +0600 +++ psmisc-21.6/src/pstree.c 2005-06-05 10:49:07.000000000 +0600 @@ -757,7 +757,6 @@ const struct passwd *pw; pid_t pid, highlight; char termcap_area[1024]; - char *termname; int c; char *tmpstr; @@ -788,15 +787,6 @@ if (!strcmp(nl_langinfo(CODESET), "UTF-8")) { /* Use UTF-8 symbols if the locale's character set is UTF-8. */ sym = &sym_utf; - } else if ((termname = getenv ("TERM")) && \ - (strlen (termname) > 0) && \ - (setupterm (NULL, 1 /* stdout */, NULL) == OK) && \ - (tigetstr ("acsc") > 0)) { - /* - * Failing that, if TERM is defined, a non-null value, and the terminal - * has the VT100 graphics charset, use it. - */ - sym = &sym_vt100; } else { /* Otherwise, fall back to ASCII. */ sym = &sym_ascii;
Submitted by: Alexander E. Patrakov Date: 2005-06-05 Initial Package Version: 21.6 Upstream Status: Not Submitted - Test version Origin: Alexander E. Patrakov Description: This patch fixes some (but not all) bugs resulting from improper use of VT100 line drawing characters by pstree. Detalils: Use of VT100 line drawing characters is the origin of at least two important bugs: 1) In non-ISO-8859-1 8-bit locales on Linux console, pstree sends the \033(0 escape sequence to the terminal. This means "Use ISO-8859-1 translation table" and therefore breaks the display of all national characters after running pstree. (echo -e '\033(K' is the fix). 2) pstree may break line without turning off ACS mode. If this happens in the last line of output, the subsequent bash prompt and everything else is turned into meaningless line-drawing characters. Example: http://sourceforge.net/tracker/index.php?func=detail&aid=1195650&group_id=15273&atid=115273 These two bugs are fixed, but the fix is not 100% correct: VT_END contains two escape sequences, one for linux console and one for xterm. The patch relies upon the fact that each of those two terminals ignores the escape sequence for the other terminal type. There are other, unfixed bugs, e. g. misaligning of line-drawing characters in Konsole and cutting the line at less than 80 columns. --- psmisc-21.6/src/pstree.c.orig 2005-06-05 10:43:16.000000000 +0600 +++ psmisc-21.6/src/pstree.c 2005-06-05 11:11:15.000000000 +0600 @@ -43,7 +43,7 @@ #define UTF_HD "\342\224\254" /* U+252C, Horizontal and down */ #define VT_BEG "\033(0\017" /* use graphic chars */ -#define VT_END "\033(B" /* back to normal char set */ +#define VT_END "\033(B\033(K" /* back to normal char set */ #define VT_V "x" /* see UTF definitions above */ #define VT_VR "t" #define VT_H "q" @@ -82,10 +82,11 @@ const char *last_2; /* `- */ const char *single_3; /* --- */ const char *first_3; /* -+- */ + const char *new_line; } sym_ascii = { -" ", "|-", "| ", "`-", "---", "-+-"} +" ", "|-", "| ", "`-", "---", "-+-", "\n"} , sym_utf = { @@ -93,13 +94,13 @@ UTF_VR UTF_H, UTF_V " ", - UTF_UR UTF_H, UTF_H UTF_H UTF_H, UTF_H UTF_HD UTF_H}, sym_vt100 = + UTF_UR UTF_H, UTF_H UTF_H UTF_H, UTF_H UTF_HD UTF_H, "\n"}, sym_vt100 = { " ", VT_BEG VT_VR VT_H VT_END, VT_BEG VT_V VT_END " ", VT_BEG VT_UR VT_H VT_END, - VT_BEG VT_H VT_H VT_H VT_END, VT_BEG VT_H VT_HD VT_H VT_END} + VT_BEG VT_H VT_H VT_H VT_END, VT_BEG VT_H VT_HD VT_H VT_END, "\n" VT_END} , *sym = &sym_ascii; @@ -199,7 +200,7 @@ if (last_char && cur_x == output_width) putchar (last_char); last_char = 0; - putchar ('\n'); + out_string(sym->new_line); cur_x = 1; }
-- http://linuxfromscratch.org/mailman/listinfo/patches FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
