[PATCH 3/3] fhandler_pty_slave::setup_locale: respect charset == "UTF-8"

Takashi Yano takashi.yano@nifty.ne.jp
Mon Sep 7 13:40:56 GMT 2020


Here is a summary of my points:

[Senario 1]
1) Start mintty (UTF-8).
2) Start another mintty by 
     mintty -o charset=SJIS
   from the first mintty.

[Senario 2]
  int pm = getpt();
  if (fork()) {
    [do the master operations]
  } else {
    setsid();
    ps = open(ptsname(pm), O_RDWR);
    close(pm);
    dup2(ps, 0);
    dup2(ps, 1);
    dup2(ps, 2);
    close(ps);
    setenv("LANG", "ja_JP.SJIS", 1);
    [exec shell]
  }


Q1) cygheap or tty shared memory?

Consider senario 1. If the term_code_page is in cygheap,
it is inherited to child process. Therefore, the second
mintty cannot update term_code_page while locale is changed.

Consider senario 2. Since only the child process knows the
locale, master (parent process) cannot get term_code_page
if it is in cygheap.

Q2) Is checking environment necessary?

As for senario 2, setlocale() is not called. So it is
necessary to check environment to know locale.

Q3) Where and when should term_code_page be set?

In senario 2, LANG is set just before exec() in the CHILD
process. Therefore, term_code_page should be determined
in the child_info_spawn:worker or in the execed process.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>


More information about the Cygwin-patches mailing list