On Thu, 21 Jul 2011 18:39:31 -0400, Vladimir Panteleev <[email protected]> wrote:

On Thu, 21 Jul 2011 18:47:03 +0300, Steven Schveighoffer <[email protected]> wrote:


In fact, my windows changes are merged into Lars' branch (https://github.com/kyllingstad/phobos/tree/new-std-process)

*BUT* (and this is a big but), dmc's runtime incorrectly handles pipes with C's stdio (i.e. FILE *). Since everything in D right now is FILE * based, it means you can't use pipes at all.

However, I have submitted a patch for DMC's runtime to Walter. Hopefully it will be approved in the near future, and then we can work on merging the new std.process into phobos.

I didn't know it was possible to wrap a Windows pipe in a FILE.

Well, under the hood, the runtime ends up using Windows HANDLES. In fact, a DMC file descriptor is just an index into a global array of HANDLES. I had to create a druntime function to wrap a HANDLE in a file descriptor (and get the handle from the fd).

The bug in the runtime essentially is that when the pipe is closed from the write end, a read of the file descriptor results in EBADF. This makes the FILE * report it as error instead of EOF. In fact, I think the error should be EPIPE, but dmc's low level handler returns BADF no matter what error occurred when doing ReadFile.

Neither did I know that the source to DMC's runtime is available.

It is if you purchase a license ;)

Would it be possible to fix the ridiculously low open FILE limit on Windows as well?

It's just a #define, but I'm not sure what the effects would be everywhere. You'd probably have to petition Walter for that.

And it's not FILE limit, it's the file descriptor limit (set to 60 in stdio.h).

-Steve

Reply via email to