From: Jonathan de Boyne Pollard on
>
>>>
>>> Strange hang problem with ReadFile.
>>>
>>
>> You're leaving the write end of a pipe open. Since your variable
>> names are confusing, and you appear to be duplicating handles for the
>> fun of it, I've not looked to see which handle(s) this is.
>>
> The write end of the pipe gets closed at the end. Is there a problem
> with it open?
>
Yes, and it's the obvious one: The read end won't see EOF until it is
closed.

> All that handle duplication came from the Microsoft's example. I
> didn't invent it. If there is a better way, I'll be happy to use it.
>
Cargo cult programming is never the answer. You need to understand why
the example is doing what it is doing. At the very least you need to
read the comments in the example, including the ones that you didn't
copy. Now that I know that you copied this from an example in a MSKB
article, I know what to look for, and I find that the example actually
warns about the error that you are making.

From: IlyaK on
Can you please point out where the error is?
Obviously I don't see it.


> Cargo cult programming is never the answer.  You need to understand why
> the example is doing what it is doing.  At the very least you need to
> read the comments in the example, including the ones that you didn't
> copy.  Now that I know that you copied this from an example in a MSKB
> article, I know what to look for, and I find that the example actually
> warns about the error that you are making.

From: IlyaK on
Can you please point out where the error is?
Obviously I don't see it.


> Cargo cult programming is never the answer.  You need to understand why
> the example is doing what it is doing.  At the very least you need to
> read the comments in the example, including the ones that you didn't
> copy.  Now that I know that you copied this from an example in a MSKB
> article, I know what to look for, and I find that the example actually
> warns about the error that you are making.

From: IlyaK on
Hi Hector:

This algorithm is working!
There is, however, one small caveat. It has to check if numRead ==
iBufferSize. If true, then there is more data and it should read again
before exiting.

Thanks for help.
From: rogero on
On Mar 3, 7:51 pm, IlyaK <katsnel...(a)gmail.com> wrote:
> Can you please point out where the error is?
> Obviously I don't see it.

Apply the following:
- The read will return zero when the last write handle to the pipe
closes.
- The child process has completed, so it can't be holding handles.

So who has this handle open?

The main process.
So close *that* copy of the handle and it'll work as expected.

Regards,
Roger.