forks/pipes and std.socket

Steven Schveighoffer schveiguy at yahoo.com
Thu Sep 9 13:40:50 PDT 2010


On Thu, 09 Sep 2010 16:25:44 -0400, Nick Sabalausky <a at a.a> wrote:

> "Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message
> news:op.vipr20xfeav7ka at localhost.localdomain...
>> On Tue, 07 Sep 2010 16:51:48 -0400, Nick Sabalausky <a at a.a> wrote:
>>
>>>
>>> Ah cool, looking forward to it. I was just about ready to launch into a
>>> bunch of std.process improvements myself ;) In the meantime, it seems
>>> that
>>> File has an undocumented constructor that takes a file handle instead  
>>> of
>>> a
>>> filename, so that should work for me.
>>
>> Beware, it takes a file *descriptor*, which is different from a *HANDLE*
>> on windows.  In writing the updated std.process I had to write D code  
>> that
>> mimics the internals of DMC's runtime in order to translate between file
>> descriptors and handles, not a pretty sight...
>>
>
> I'm just feeding it the values I get from CreatePipe:
> http://msdn.microsoft.com/en-us/library/aa365152(VS.85).aspx
>
> Seems to be working fine, though...

That won't work.  I'm surprised it works at all.  DMC maintains the list  
of handles in an array, with the index of the array being the file  
descriptor, and the value at that element being the HANDLE.  If it's  
working, you're extremely lucky that the unallocated slot at the index  
that happens to be that HANDLE value has the same value as the HANDLE  
itself.

Or maybe I'm misunderstanding something...  Walter?

-Steve


More information about the Digitalmars-d-learn mailing list