On Thu, Jul 15, 2010 at 12:25:09PM +0100, Andy Koppe wrote: >On 15 July 2010 09:19, Corinna Vinschen wrote: >>> Furthermore, 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*. >> >> Right. >> >>> [...] >>> 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.) >> >> That sounds like an interesting idea. ??I'll play around with it as soon >> as I have a bit of spare time again. ??Unless, of course, nobody else >> will try it or already did... > >It would be brilliant if this did work, taking at least some of the >sting out of the whole pty vs interactive console app issue.
I actually have thought about doing this in the past but it always seemed to me that lying to a program about the "ttyness" of a file handle was going to cause more subtle problems than what we have currently. It also obviously isn't a panacea since not everything is going to use msvcrt file handles. If we really can create a standard file handle structure and not have to tweak it for the next five years and if we only fill it out for non-cygwin programs (which we do know when we're about to exec something) maybe it will be worth it. I think I'm going to need some real convincing though. Hmm. I wonder if anything else does this. Does MKS do something similar? 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