question about ReadFile on pipes

"Ben Wing" <[email protected]>
Newsgroups gmane.emacs.xemacs.windows
Message-ID <01d801c2e148$c937fde0$0201a8c0@neeeeeee>
i noticed recently that the helper program i.exe chews up tons of CPU time,
which seemed very strange.

the problem is this:

  while (ReadFile (pi->source, buffer, sizeof (buffer), &really_read, NULL) &&
  WriteFile (pi->drain, buffer, really_read, &unused, NULL))
    ;

the docs for ReadFile say:

The ReadFile function returns when one of the following is true: a write
operation completes on the write end of the pipe, the number of bytes requested
has been read, or an error occurs.

but this is obviously not true, at least on my win2000 system.  putting in some
printf's shows that ReadFile *never* blocks, and instead just returns 0 bytes.
adding Sleep(100) fixes things but this is a kludge.

what's going on here?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.