mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-19 07:22:14 +08:00
- Usually WriteQuotaAvailable retrieved by NtQueryInformationFile() on the write side reflects the space available in the inbound buffer on the read side. However, if a pipe read is currently pending, WriteQuotaAvailable on the write side is decremented by the number of bytes the read side is requesting. So it's possible (even likely) that WriteQuotaAvailable is 0, even if the inbound buffer on the read side is not full. This can lead to a deadlock situation: The reader is waiting for data, but select on the writer side assumes that no space is available in the read side inbound buffer. Currently, to avoid this stuation, read() does not request larger block than pipe size - 1. However, this mechanism does not take effect if the reader side is non-cygwin app. The only reliable information is available on the read side, so fetch info from the read side via the pipe-specific query handle (query_hdl) introduced. If the query_hdl (read handle) is kept in write side, writer can not detect closure of read pipe. Therefore, raw_write() counts write handle and query_hdl. If they are equal, only the pairs of write handle and query_hdl are alive. In this case, raw_write() returns EPIPE and raises SIGPIPE. - Nonblocking pipes (PIPE_NOWAIT) are not well handled by non-Cygwin tools, so convert pipe handles to PIPE_WAIT handles when spawning a non-Cygwin process.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cygwin documentation is available on the net at https://cygwin.com You might especially be interested in https://cygwin.com/faq/faq.html#faq.programming.building-cygwin