www.delorie.com/archives/browse.cgi | search |
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:subject:to:references:from:message-id:date | |
:mime-version:in-reply-to:content-type | |
:content-transfer-encoding; q=dns; s=default; b=OtUnYp2nzGjlQ4NY | |
qv/8LFKcdTLSY3Qx1s0i8/v80zlp4jSe8DdY2TcB3wiwm5fjJJCqc1GxAM+IaYBv | |
kpnCkWkW5ElxsHoxX2g695OF3qTnZg9UQeSgogH+iVzyVio+kSnanOz/VgmmDthv | |
MPIXjOX6glEilukAC32qRuxemxs= | |
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:subject:to:references:from:message-id:date | |
:mime-version:in-reply-to:content-type | |
:content-transfer-encoding; s=default; bh=ys3KSkgVwVLAuYTmmxTAaU | |
WCYZo=; b=m1izEBQ9SaHZy54Ua9czFgVj4ISsnEA8mhHRDDEr9OyCPkLg7g3FJV | |
fquFY9gkMOE9+XO5mYrUyWdx8h09sl6p67jPHCfHrClLOJ12KVZItmty52trkpTW | |
RHW3uoJvTCAmrzxUg/SCWiPDdMUHIEf3UyEKPlcF1pv0BJXUaRGcI= | |
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=-1.7 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=Strange, bray, Bray, Erik |
X-HELO: | mout.kundenserver.de |
Subject: | Re: Strange bug with /dev/console in mintty |
To: | cygwin AT cygwin DOT com |
References: | <CAOTD34aibcY2oOq1o_kHfT5HVxEh97-c73mMEZMwa9S1hUrXTg AT mail DOT gmail DOT com> |
From: | Thomas Wolff <towo AT towo DOT net> |
Message-ID: | <caebfd65-1d2f-9e0c-67cd-28e1c8219dd0@towo.net> |
Date: | Tue, 22 Aug 2017 23:31:57 +0200 |
User-Agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
MIME-Version: | 1.0 |
In-Reply-To: | <CAOTD34aibcY2oOq1o_kHfT5HVxEh97-c73mMEZMwa9S1hUrXTg@mail.gmail.com> |
X-UI-Out-Filterresults: | notjunk:1;V01:K0:5FytuKaJsRw=:YLjq8UB1JWuw0byLvsQH/8 IIh8XBS8e8J1ucVjihLYGBEOSMuJNPP0+2H3uJEOC8fW2eKYbZRzRnISZUuP2SbT/jPLxzvMN D5cxuRrO0URQU9WVaSQf8f4XlbBThomycYD7QTAriDX8FamMJDsv0QGDNbkCntOIlTEaf+Gma 4qLvouWQIC5x2+Gv6YqIOi5QWpmDVwRfdFHHhArczIgKB0aqZBATKojv/pJNaTQgAJZeRlYNM O2HmaagpVdXadx1s6LIwu6zzMCuF4LI7iIqYeCcEhSN0d4qxNeCqFlKO6JNBnHLsIQ5drDQO9 rBYPfGJKJQXWokb9LToKFxPYO2dkD67iDmyVL/vPxLXZ0VxyQvj5eH6iQyboAXtv1BEVga68w TEgO5fZESmoJfNHhLqwCJwgg0jUCDc3ZemYiDFaQZT2tXO4PbhddVxJ3xni/vgPaeHc/IcDdW VA3kHX7WQscadLK49F4cv2xbZbJ3o5y8bbCTo83ELzkXJkNkR7WQTB6vHoYrk7K8m49cdme6L cuFk/mMogcZe3+2LqHYGQ3xF0nbYZarOzjlPLz9p5z+9YZxcRYSf0pbH5VibrAAeFnOiAejo8 L6kk5OuAWrqe3PSVjI95YY1tyIMUNHvet88FguUBG3SrQWps9qm+jbvtdor/U5h/TgOBKiSlY bYKF82l/2YcwXyeJH53dC7Nbq5tmWAgLTwR+bAVELoKaHyOzYIyKAKZFDK9afhRoDHp0id1Zx qS3L9VN5sdAmY444iuevOSQ4xDAGtGYnTT2Kgr9ArKTrIeUKOzZ1FgE9Cj8= |
X-IsSubscribed: | yes |
Am 22.08.2017 um 18:49 schrieb Erik Bray: > Hi folks, > > 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: > > $ 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 > > The same command when run in mintty returns: > > 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 > > 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: > > 203 if (cdev->get_major () == 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 number > 209 as the current consX. */ > 210 de->d_ino = myself->ctty; > 211 } > > where myself->ctty seems to depend largely on what file types the > stdio handles are attached to. > > 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: > > $ ls -l /dev/console > ls: cannot access '/dev/console': No such device or address The device to refer to one's own session is /dev/tty, not /dev/console. It is not quite obvious how to map the concept of a unique /dev/console to modern environments, esp. Cygwin. Maybe it would help if you describe your intended use case. > which is the error message for a ENXIO. This is coming specifically > from the function build_fh_pc in dtable.cc. The reason is that trying > to access /dev/console results in trying to create an fhandler_console > for a non-existent console. > > I'm not really sure what the correct behavior should be here though, > and if it should be fixed on the mintty side or the Cygwin side. This is certainly not related to mintty, but likely to pty handling, as your own code findings already suggest. Thomas -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |