delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/08/23/04:38:02

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=URsyY//D36/hxHHS+4BA6zDyalvTyF8xkdpXg6iz/SM4mZif3ksx/
paPGRARwtNzzlm8xx1CNYrZL82NXjScOR/jGHQvP9SoUxQon6uBesBktuXyoILKI
ARYTGJ5qYbj3YweLWO6trUra0BCNPKwzhBTSd0sWfBCh4lnsXLgbxI=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=6nnaqBRf0bCc+41nKtmy1Nf/p4A=; b=cA5h6pc8zkWJZsQipH2G/BlvmJ/V
302wyuFSQcaryP9PHCK6UMqO0tnw3ODgcPXXREGVKZdDI493M77rbmEgjolJV+xN
hL+OEdbobaQGGRwnPHJD/V67sNDOoxvmfz5hTavyuPVNWvzndsILIZb0M23kA021
CFxKt5dL+3ZUIFI=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-101.9 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=friends, H*c:application
X-HELO: drew.franken.de
Date: Wed, 23 Aug 2017 10:33:46 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Strange bug with /dev/console in mintty
Message-ID: <20170823083346.GB7469@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <CAOTD34aibcY2oOq1o_kHfT5HVxEh97-c73mMEZMwa9S1hUrXTg AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <CAOTD34aibcY2oOq1o_kHfT5HVxEh97-c73mMEZMwa9S1hUrXTg@mail.gmail.com>
User-Agent: Mutt/1.8.3 (2017-05-23)

--bCsyhTFzCvuiizWE
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Aug 22 18:49, Erik Bray wrote:
> Hi folks,
>=20
> I noticed a strange discrepancy when running Cygwin through mintty, vs
> through a normal cmd.exe console.  This is on a build from the latest
> git master, but also on Cygwin 2.8.0.  When run from a cmd.exe
> console, we can see the following output from fhandler_dev::readdir:
>=20
> $ ls -l /dev/con*
> crw-rw-rw- 4 Erik M. Bray Erik M. Bray 3, 0 Aug 22 18:29 /dev/conin
> crw-rw-rw- 4 Erik M. Bray Erik M. Bray 3, 0 Aug 22 18:29 /dev/conout
> crw-rw-rw- 4 Erik M. Bray Erik M. Bray 3, 0 Aug 22 18:29 /dev/cons0
> crw-rw-rw- 4 Erik M. Bray Erik M. Bray 3, 0 Aug 22 18:29 /dev/console
>=20
> The same command when run in mintty returns:
>=20
> crw-rw-rw- 1 Erik M. Bray Erik M. Bray 5, 255 Aug 22 18:29 /dev/conin
> crw-rw-rw- 1 Erik M. Bray Erik M. Bray 5, 254 Aug 22 18:29 /dev/conout
> crw-rw-rw- 1 Erik M. Bray Erik M. Bray 5,   1 Aug 22 18:29 /dev/console
>=20
> In the latter case, the device numbers are the default device numbers
> for /dev/console, etc.  In the former case, the inodes for
> /dev/console, /dev/conin, and /dev/conout are set to the same as
> /dev/cons0.  This logic can be found in fhandler_dev::readdir:
>=20
> 203       if (cdev->get_major () =3D=3D DEV_TTY_MAJOR
> 204       && (cdev->is_device (FH_CONIN)
> 205           || cdev->is_device (FH_CONOUT)
> 206           || cdev->is_device (FH_CONSOLE)))
> 207     {
> 208       /* Make sure conin, conout, and console have the same inode num=
ber
> 209          as the current consX. */
> 210       de->d_ino =3D myself->ctty;
> 211     }
>=20
> where myself->ctty seems to depend largely on what file types the
> stdio handles are attached to.
>=20
> When running from cmd.exe, GetStdHandle(...) returns handles to a
> character stream--i.e. the console itself.  However, when running from
> mintty it returns pipes (specifically, to a pty, probably related to
> the call to forkpty in mintty).  In Cygwin (particularly, in
> dtable::init_std_file_from_handle) the result ends up being that when
> the stdio handles are pipes, the /dev/cons0 device never gets created.
> And thus /dev/console and friends never get rerouted to a real device.
> This results in errors when trying to access /dev/console directly:
>=20
> $ ls -l /dev/console
> ls: cannot access '/dev/console': No such device or address

/dev/console is an old concept in Cygwin and it was always attached to
the current console window, *if* you were running inside a windows
console.  It was never implemented for pseudo ttys as used by mintty.

The fact that the /dev emulation shows the con devices is a bit
disappointing, given that they are basically unusable.  The existence
check only checks if GetConsoleCP() returns successfully, but that's
true for a pseudo tty as well.  A console is attached to the process
anyway.

I'll think about the existence check.


Corinna

--=20
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--bCsyhTFzCvuiizWE
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJZnT3qAAoJEPU2Bp2uRE+g6jsP/R6Y1h2ToLHXKwUk3PYFuE49
qarDW8g4RTY5F5PM9AzL7pA8VE2U8OSd/wfcQhu0U2ygild3PFSV0tyR8MiQ7R2W
YiUlajK2X6YBGxyTIhxunoOfX3r8GJJhn12FVpOYV8/ncyV9Il6DSr6hmA2F6EQx
83euiYPzkvVbTmDsilEqyqoIwCcGISMQXYREo7CHawrh3Oc9+PCrakXUjrxZue4C
TbtL57VXQ2Ct1+wZMn/96+Z3C1VvefBJY7Z9kW5Mtut7rnW8Ms10c4qY7Z90Qyma
8SIZwSx7qA6MDiQ0waXZVzG5uWr60Luv/TSKuGwnnXWOJhMgUE4nlXA9ilxTO5mT
XE28hYMopgThzjzfbaLCcYoxkApcQI+xj6LUaLQdCxk2Rv1r6yfmv6gnCmGHhl/C
cymF3oBSgQRydLkK9fZit7wsnCP56BScrHLKdO6pKTDPoDZtrSzLyaBQBXbNdQ1f
J+mqKnme0G74xjMIoOjk43HQvDY/Bu3yA+zCeDwTv3aGpo03ka4lFBhYkZjl+hsP
Bhuw424iGKkdSyhLXcktlZvM1n+8qHyfZnBcMRP6M5hP2ShaCX5F+cneWwgX337+
LVUjje6WmZYvFSBb2yznsiNBn+RzrcFeiFh/hzaBmxVWc/t8GUZSBSGiPSKkasaX
zU39snylpZR7DGpSjJEH
=2ttQ
-----END PGP SIGNATURE-----

--bCsyhTFzCvuiizWE--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019