piping processes

Regan Heath regan at netmail.co.nz
Thu Dec 1 03:54:31 PST 2011

On Thu, 01 Dec 2011 11:29:52 -0000, Andrej Mitrovic  
<andrej.mitrovich at gmail.com> wrote:

> I can't find my thread in the archives yet, but I made a similar
> inquiry a few days ago.
> You can see a few examples for Windows here:
> https://github.com/AndrejMitrovic/DWinProgramming/tree/master/Samples/Extra/RedirectChildHandle
> https://github.com/AndrejMitrovic/DWinProgramming/tree/master/Samples/Extra/RedirectChildHandleThreaded

Oddly I haven't used the SetHandleInformation function for this.. I wonder  
if it arrived /after/ I learnt all this :p

I know these are basic examples, but I think in RedirectChildHandle.d,  
CreateChildProcess, you should (ideally) be closing childStdoutWrite and  
childStdinRead /after/ CreateProcess.  If you don't you get 2 copies of  
them, one in the child and one in the parent.  If the child closes it's  
copy the parent will not notice the pipe close (when reading from the  
other end of the pipe - for example).  If you close it, it will mean that  
you will actually drop out of a blocking read in the parent immediately  
(when the child terminates), rather than timing out and then discovering  
the child has terminated (using the thread or process handle).


Using Opera's revolutionary email client: http://www.opera.com/mail/

More information about the Digitalmars-d-learn mailing list