X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,TW_RG,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org MIME-Version: 1.0 In-Reply-To: <4C8D4877.7030107@gmail.com> References: <000801cb2383$9c3ad3a0$d4b07ae0$@gmail.com> <20100714184922 DOT GA13548 AT ednor DOT casa DOT cgf DOT cx> <001001cb23a5$3a879090$af96b1b0$@gmail.com> <4C8D4877 DOT 7030107 AT gmail DOT com> Date: Sun, 12 Sep 2010 23:06:36 +0100 Message-ID: Subject: Re: {lp,cb}Reserved2 under Windows 7 and file descriptors From: Andy Koppe To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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 12 September 2010 22:39, Daniel Colascione wrote: > On 9/12/10 2:29 PM, Andy Koppe wrote: >> This does appear to work! Proof-of-concept code attached, along with a >> couple of tests. Running in mintty: > > Awesome. Thanks for doing this work. I believe the Cygwin developers had > concerns about this change inadvertently breaking some applications. > Have you noticed any unusual behavior? Nope, but of course I've only tried a few things. >> Unfortunately it only seems to work for fdev's direct child process >> though. For example, when running cmd.exe through fdev and invoking >> isatty.exe from there, it's all zeroes from isatty() again. > > Unfortunately, cmd.exe does not appear to use the C runtime IO library, > and it doesn't pass on inherited file descriptors --- except for the > standard handles via CreateProcess. It's a shame, too, because cmd > understands the syntax for manipulating the first ten file descriptors > in much the same way that a unix shell does. > > I think it would work for other families of process though, and it's > still an improvement. Yep. And it turns out it does actually work for child processes too if they're created through spawn() rather than CreateProcess: $ cat spawn.c #include int main(int argc, const char *argv[]) { return spawnv(P_WAIT, argv[1], argv + 1); }; $ gcc-3 -mno-cygwin spawn.c -o spawn $ ./fdev "./spawn ./isatty" isatty(0)=64 isatty(1)=64 isatty(2)=64 Andy -- 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