From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-developers@cygwin.com
Subject: Re: [PATCH v5 1/1] Cygwin: pty: add pseudo console support.
Date: Tue, 16 Apr 2019 09:16:00 -0000 [thread overview]
Message-ID: <20190416091616.GN3599@calimero.vinschen.de> (raw)
In-Reply-To: <20190416094143.c612b1d9262bd015a8103f10@nifty.ne.jp>
[-- Attachment #1: Type: text/plain, Size: 2857 bytes --]
On Apr 16 09:41, Takashi Yano wrote:
> On Mon, 15 Apr 2019 10:38:32 +0200 Corinna Vinschen wrote:
> > This is supposed to be combined with the preceeding code to a single
> > expression in the end, right?
>
> Do you mean this code and the preceding code should be executed
> exclusively? If so, the answer is no. If the stderr is pty slave,
> the message should be written to both output_handle and
> output_handle_cyg. The reason will be described later.
>
> > I don't quite understand why writing
> > to STD_ERROR_HANDLE doesn't work. Is STD_ERROR_HANDLE not connected
> > to the ConPty?
>
> You are right. STD_ERROR_HANDLE (output_handle) is connected to
> the ConPTY. The data written to output_handle is fowarded to
> to_master_cyg in the master, then displayed. to_master_cyg is
> duplicated to output_handle_cyg in the slave. Therefore, both
> writing to output_handle and writing to output_handle_cyg seem
> to work, at first glance.
>
> However, in the fact, the code below stops forwarding if the
> process is a cygwin process.
> + /* Avoid duplicating slave output which is already sent to
> + to_master_cyg */
> + if (!get_ttyp ()->switch_to_pcon)
> + continue;
>
> The role of the code above is as follows. ConPTY sometimes redraws
> screen based on its own screen buffer. The screen buffer has only
> the data written to output_handle. Basically, cygwin apps use
> output_handle_cyg and native apps use output_handle. Terefore,
> outputs from cygwin apps are disappeared at that time. To avoid
> this, the data write to output_handle_cyg is pushed into the ConPTY
> screen buffer by WriteFile() to output_handle. To prevent the data
> from being displayed twice, forwarding is stopped by the code above
> if the process is a cygwin app.
>
> In strace.cc, writing to output_handle is necessary for pushing
> the data into ConPTY screen buffer, and writing to output_handle_cyg
> is necessary for displaying it.
Huh, crazy. Thanks for explaining the context.
>
> > > + fhandler_base *fh = ::cygheap->fdtab[2];
> > > + if (fh && fh->get_major () == DEV_PTYS_MAJOR)
> >
> > For a quick test if the process is connected to a pty, you can
> > use `if (istty_slave_dev (myself->ctty))'
>
> Thanks for advice. My code is checking if the stderr is pty or
> not, and write the message to output_handle_cyg if the stderr
> is pty. If the stderr is redirected to another device, writing
> is not done. Does istty_slave_dev() checking work same for
> stderr if it is redirected? How can I get output_handle_cyg
> after checking using istty_slave_dev()?
Well... I didn't really think about it. YOu would have to
fetch ::cygheap->fdtab[2] anyway so checking myself->ctty
doesn't really help.
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-04-16 9:16 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-30 13:08 Pseudo console support in PTY Takashi Yano
2019-03-30 19:47 ` Corinna Vinschen
2019-03-30 19:59 ` Corinna Vinschen
2019-03-30 23:07 ` Thomas Wolff
2019-03-31 14:38 ` Corinna Vinschen
2019-03-31 15:00 ` Takashi Yano
2019-04-02 11:02 ` Corinna Vinschen
2019-04-02 17:16 ` Thomas Wolff
2019-04-02 17:51 ` Corinna Vinschen
2019-04-03 7:18 ` Thomas Wolff
2019-04-03 7:28 ` Corinna Vinschen
2019-04-03 7:55 ` Thomas Wolff
2019-04-03 8:02 ` Corinna Vinschen
2019-04-03 11:33 ` Thomas Wolff
2019-04-03 12:17 ` Corinna Vinschen
2019-04-04 4:17 ` Takashi Yano
2019-04-04 8:06 ` Corinna Vinschen
2019-04-04 4:15 ` Takashi Yano
2019-04-03 16:36 ` [PATCH v2 0/1] Pseudo console support in PTY (v2) Takashi Yano
2019-04-03 16:37 ` [PATCH v2 1/1] Cygwin: pty: add pseudo console support Takashi Yano
2019-04-03 16:50 ` [PATCH v2 0/1] Pseudo console support in PTY (v2) Corinna Vinschen
2019-04-04 5:27 ` Takashi Yano
2019-04-04 8:17 ` Thomas Wolff
2019-04-04 9:34 ` Takashi Yano
2019-04-03 17:11 ` Corinna Vinschen
2019-04-04 8:59 ` Takashi Yano
2019-04-04 10:46 ` Corinna Vinschen
2019-04-06 11:13 ` [PATCH v3 0/1] Pseudo console support in PTY (v3) Takashi Yano
2019-04-06 11:14 ` [PATCH v3 1/1] Cygwin: pty: add pseudo console support Takashi Yano
2019-04-06 17:43 ` [PATCH v3 0/1] Pseudo console support in PTY (v3) Corinna Vinschen
2019-04-12 10:22 ` [PATCH v4 0/1] Pseudo console support in PTY (v4) Takashi Yano
2019-04-12 10:23 ` [PATCH v4 1/1] Cygwin: pty: add pseudo console support Takashi Yano
2019-04-12 12:29 ` [PATCH v4 0/1] Pseudo console support in PTY (v4) Corinna Vinschen
2019-04-15 8:18 ` Corinna Vinschen
2019-04-15 23:17 ` Takashi Yano
2019-04-14 15:23 ` [PATCH v5 0/1] Pseudo console support in PTY (v5) Takashi Yano
2019-04-14 15:23 ` [PATCH v5 1/1] Cygwin: pty: add pseudo console support Takashi Yano
2019-04-15 8:38 ` Corinna Vinschen
2019-04-16 0:41 ` Takashi Yano
2019-04-16 9:16 ` Corinna Vinschen [this message]
2019-06-24 10:53 ` Corinna Vinschen
2019-07-25 14:31 ` Corinna Vinschen
2019-08-08 19:24 ` Corinna Vinschen
2019-08-12 12:07 ` Takashi Yano
2019-08-12 12:50 ` Corinna Vinschen
2019-08-12 14:36 ` Takashi Yano
2019-04-14 16:06 ` [PATCH v5 0/1] Pseudo console support in PTY (v5) Takashi Yano
2019-04-16 1:49 ` Takashi Yano
2019-04-16 1:51 ` Takashi Yano
2019-04-06 21:33 ` [PATCH v3 0/1] Pseudo console support in PTY (v3) Thomas Wolff
2019-04-07 5:05 ` Takashi Yano
2019-04-07 12:02 ` Takashi Yano
2019-04-07 21:21 ` Thomas Wolff
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=20190416091616.GN3599@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin-developers@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).