On May 7 16:21, Ken Brown via Cygwin-patches wrote: > This project began as a an attempt to allow a FIFO to be opened > multiple times for reading. The initial motivation was that Midnight > Commander running under tcsh does this (unsuccessfully on Cygwin). > See > > https://sourceware.org/pipermail/cygwin/2019-December/243317.html > > It quickly became apparent, however, that the current code doesn't > even properly handle the case where the FIFO is *explicitly* opened > only once for reading, but additional readers are created via > dup/fork/exec. > > This explained some of the bugs reported by Kristian Ivarsson. See, > for example, the thread starting here: > > https://sourceware.org/pipermail/cygwin/2020-March/000206.html > > as well as later similar threads. > > [The discussion continued in private email, with many bug reports and > test programs by Kristian. I'm very grateful to him for his reports > and testing.] > > The first 10 patches in this series make some improvements and bug > fixes that came up along the way and don't specifically relate to > multiple readers. The next 10 patches, with the exception of "allow > fc_handler list to grow dynamically", add the support for multiple > readers. The last one updates the commentary at the beginning of > fhandler_fifo.cc that tries to explain how it all works. > > The key ideas in these patches are: > > 1. Use shared memory, so that all readers have the necessary > information about the writers that are open. > > 2. Designate one reader as the "owner". This reader runs a thread > that listens for connections and keeps track of the writers. > > 3. Use a second shared memory block to be used for transfer of > ownership. Ownership must be transferred when the owner closes or > execs. And a reader that wants to read or run select must take > ownership in order to be able to poll the writers for input.
This looks great. Please push at your own discretion. Thanks, Corinna -- Corinna Vinschen Cygwin Maintainer