delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/09/12/18:41:34

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Sun, 12 Sep 2010 18:41:08 -0400
From: Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: {lp,cb}Reserved2 under Windows 7 and file descriptors
Message-ID: <20100912224108.GA18097@ednor.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <000801cb2383$9c3ad3a0$d4b07ae0$@gmail.com> <20100714184922 DOT GA13548 AT ednor DOT casa DOT cgf DOT cx> <001001cb23a5$3a879090$af96b1b0$@gmail.com> <AANLkTimpz7mghcPDk=tt7xCXkrgruoGf6+bCReM3KziG AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <AANLkTimpz7mghcPDk=tt7xCXkrgruoGf6+bCReM3KziG@mail.gmail.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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

On Sun, Sep 12, 2010 at 10:29:56PM +0100, Andy Koppe wrote:
>On 14 July 2010 23:38, Daniel Colascione wrote:
>>there is a very long-standing issue with Cygwin pty devices: while
>>Cygwin programs report true from isatty() when called on a Cygwin PTY,
>>MSVCRT applications do *not*.  From their point of view, Cygwin ptys
>>are not ttys, which has led to all sorts of trouble over the years.
>>Because Windows lacks a pseudoconsole facility, it's not possible to
>>solve the problem in general (though some people, like the author of
>>conin, have taken some steps in that direction).
>>
>>However, due to the way the CRT works, we can fool it into thinking a
>>passed-in file descriptor is actually a tty.  All you need to do is use
>>3 for the value of *lpReserved2, then follow it with three flag bytes,
>>then three HANDLE values --- corresponding respectively to flags[fd0],
>>flags[fd1], flags[fd2] and fh[0], fh[fd1] and fh[fd2].  ??This
>>information would be followed by the normal child_info structure.  If
>>stdin, stdout, or stderr is a Cygwin PTY, Cygwin can manually set the
>>FDEV bit (described in the old MSDOS headers) in corresponding flag
>>byte, which will make _isatty() return true in the child.
>>
>>(Not that I've actually tried it --- it's just an idea.)
>
>This does appear to work! Proof-of-concept code attached, along with a
>couple of tests.  Running in mintty:

I'll say it again more forcefully this time: I thought of this many
years ago.  I went as far as looking into what was expected to be passed
in *Reserved2 and eventually figured out what to pass in those fields
for Cygwin's use without stepping on Windows crt.

I never tried to implement it in full because I don't like the idea of
lying to a windows process.  I think it could cause very strange
behavior for programs that think that 'isatty()' means that they are
attached to a console.

So this wasn't just an idea which went unimplemented waiting for tuits.
It went unimplemented because I thought it was a bad idea.

cgf


--
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

- Raw text -


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