This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: {lp,cb}Reserved2 under Windows 7 and file descriptors
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 <process.h>
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