On Wed, 1 Sep 2021 10:46:24 +0200 Corinna Vinschen wrote: > On Sep 1 17:23, Takashi Yano wrote: > > On Wed, 1 Sep 2021 10:07:48 +0200 > > Corinna Vinschen wrote: > > > On Sep 1 09:16, Takashi Yano wrote: > > > > On Wed, 1 Sep 2021 08:02:20 +0900 > > > > Takashi Yano wrote: > > > > > On Tue, 31 Aug 2021 17:50:14 +0200 > > > > > Corinna Vinschen wrote: > > > > > > So for the time being I suggest the below patch on top of topic/pipe. > > > > > > It contains everything we discussed so far. > > > > > > > > > > One more thing. 'git log' cannot stop normally with 'q' with your patch. > > > > > > > > The same happes with 'yes |less'. > > > > > > > > The cause is that write side cannot detect closing read side because > > > > query_hdl (read handle) is still opened. > > > > > > Oh > > > > > > my > > > > > > god. > > > > > > > > > That kills the entire idea of keeping the read handle :( > > > > One idea is: > > > > Count read handle and write handle opned using NtQueryObject(). > > If the numbers of opened handle are equal each other, only > > the write side (pair of write handle and query_hdl) is alive. > > In this case, write() returns error. > > If read side is alive, number of read handles is greater than > > number of write handles. > > Interesting idea. But where do you do the count? The event object > will not get signalled, so WFMO will not return when performing a > blocking write. I imagined something like attached patch. Unfortunately, the attached patch seems to have bug that occasionally causes the following error while building cygwin1.dll. : error: "GCC_VERSION" redefined [-Werror] : note: this is the location of the previous definition cc1plus: all warnings being treated as errors make[1]: *** [Makefile:1942: fhandler_proc.o] Error 1 -- Takashi Yano