From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH] Cygwin: pty: Disable pseudo console if TERM is dumb or not set.
Date: Fri, 28 Aug 2020 15:45:03 +0200 [thread overview]
Message-ID: <20200828134503.GL3272@calimero.vinschen.de> (raw)
In-Reply-To: <20200826120015.1188-1-takashi.yano@nifty.ne.jp>
Hi Takashi,
On Aug 26 21:00, Takashi Yano via Cygwin-patches wrote:
> Pseudo console generates escape sequences on execution of non-cygwin
> apps. If the terminal does not support escape sequence, output will
> be garbled. This patch prevents garbled output in dumb terminal by
> disabling pseudo console.
> ---
> winsup/cygwin/spawn.cc | 36 +++++++++++++++++++++++++++++-------
> 1 file changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
> index 8308bccf3..b6d58e97a 100644
> --- a/winsup/cygwin/spawn.cc
> +++ b/winsup/cygwin/spawn.cc
> @@ -647,13 +647,35 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
> ZeroMemory (&si_pcon, sizeof (si_pcon));
> STARTUPINFOW *si_tmp = &si;
> if (!iscygwin () && ptys_primary && is_console_app (runpath))
> - if (ptys_primary->setup_pseudoconsole (&si_pcon,
> - mode != _P_OVERLAY && mode != _P_WAIT))
> - {
> - c_flags |= EXTENDED_STARTUPINFO_PRESENT;
> - si_tmp = &si_pcon.StartupInfo;
> - enable_pcon = true;
> - }
> + {
> + bool nopcon = mode != _P_OVERLAY && mode != _P_WAIT;
> + /* If TERM is "dumb" or not set, disable pseudo console */
> + if (envblock)
> + {
> + bool term_is_set = false;
> + for (PWCHAR p = envblock; *p != L'\0'; p += wcslen (p) + 1)
> + {
> + if (wcscmp (p, L"TERM=dumb") == 0)
> + nopcon = true;
> + if (wcsncmp (p, L"TERM=", 5) == 0)
> + term_is_set = true;
> + }
> + if (!term_is_set)
> + nopcon = true;
> + }
> + else
> + {
> + const char *term = getenv ("TERM");
> + if (!term || strcmp (term, "dumb") == 0)
> + nopcon = true;
> + }
> + if (ptys_primary->setup_pseudoconsole (&si_pcon, nopcon))
> + {
> + c_flags |= EXTENDED_STARTUPINFO_PRESENT;
> + si_tmp = &si_pcon.StartupInfo;
> + enable_pcon = true;
> + }
> + }
>
> loop:
> /* When ruid != euid we create the new process under the current original
> --
> 2.28.0
Would you mind to encapsulate the TERM checks into a fhandler_pty_slave
method so the TERM specific stuff is done in the fhandler code, not
in spawn.cc?
Thanks,
Corinna
next prev parent reply other threads:[~2020-08-28 13:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-26 12:00 Takashi Yano
2020-08-26 17:36 ` Corinna Vinschen
2020-08-27 4:07 ` Takashi Yano
2020-08-27 8:47 ` Corinna Vinschen
2020-08-27 8:59 ` Takashi Yano
2020-08-27 9:05 ` Corinna Vinschen
2020-08-28 13:45 ` Corinna Vinschen [this message]
2020-08-28 19:25 ` Takashi Yano
2020-08-29 11:12 ` Takashi Yano
2020-08-29 13:14 ` Takashi Yano
2020-08-29 20:25 ` Takashi Yano
2020-08-29 21:13 ` Takashi Yano
2020-08-30 7:42 ` Takashi Yano
2020-08-30 7:58 ` Takashi Yano
2020-08-30 12:49 ` Corinna Vinschen
2020-08-31 3:26 ` Takashi Yano
2020-08-31 8:16 ` Corinna Vinschen
2020-08-31 9:47 ` Takashi Yano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200828134503.GL3272@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin-patches@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).