cygwin 3.3.x: another problem that may be related to pipes

Corinna Vinschen
Mon Nov 15 16:25:07 GMT 2021

On Nov 15 23:36, Takashi Yano wrote:
> [...]
> IIUC, WaitForMultipleObject() cannot wait for pipe object.
> Only the following objects are allowed to be waited.
> Change notification
> Console input
> Event
> Memory resource notification
> Mutex
> Process
> Semaphore
> Thread
> Waitable timer

Pipe handles shouldn't be any different than the above.  Please note
that you can also wait, for instance, for socket handles, which are not
in that list either.  It's just that it's tricky and the developer is
potentially doing something which *looks* correct, but doesn't what was
intended at all.

> If you pass the pipe handle to WFMO, it imediately returns WAIT_OBJECT_0,
> so your patch will work almost same with my patch.

If it returns with WAIT_OBJECT_0, something has certainly happened on
the pipe.  The problem is that it's not clear what has happened. If push
comes to shove, it could be a completed action actually performed by
another process.

So here's another brain-dead idea:

What if we create the event even in the nonblocking case?

Considering that the pipe is nonblocking, what *should* happen is this:

- NtReadFile return STATUS_PENDING
- WFMO/cygwait even with INFINITE timeout should return almost immediately
  with WAIT_OBJECT_0
- the io.Status contains a valid status including STATUS_PIPE_EMPTY if
  there's nothing to read

*If* that works, the code in blocking and nonblocking is suddenly
almost identical.  That would be nice, wouldn't it?  If only all
the interesting cases would be well documented...


More information about the Cygwin-developers mailing list