]> sourceware.org Git - newlib-cygwin.git/commit
Cygwin: select: don't report read ready on a FIFO never opened for writing
authorKen Brown <kbrown@cornell.edu>
Fri, 23 Sep 2022 14:24:04 +0000 (10:24 -0400)
committerKen Brown <kbrown@cornell.edu>
Wed, 19 Oct 2022 12:17:50 +0000 (08:17 -0400)
commit5781871775fcba783938bc4ac645eba866711fc5
tree525f5855d36f6d30a5da2f8dc539caa90e71cb69
parent0b6342c97f08765e9873b3c52d61657c2aa596e5
Cygwin: select: don't report read ready on a FIFO never opened for writing

According to POSIX and the Linux man page, select(2) is supposed to
report read ready if a file is at EOF.  In the case of a FIFO, this
means that the pipe is empty and there are no writers.  But there
seems to be an undocumented exception, observed on Linux and other
platforms:  If no writer has ever been opened, then select(2) does not
report read ready.  This can happen if a reader is opened with
O_NONBLOCK before any writers have opened.

This commit makes Cygwin consistent with those other platforms by
introducing a special EOF test, fhandler_fifo::select_hit_eof, which
returns false if there's never been a writer opened.

To implement this we use a new variable '_writer_opened' in the FIFO's
shared memory, which is set to 1 the first time a writer opens.  New
methods writer_opened() and set_writer_opened() are used to test and
set this variable.

Addresses: https://cygwin.com/pipermail/cygwin/2022-September/252223.html
winsup/cygwin/fhandler/fifo.cc
winsup/cygwin/local_includes/fhandler.h
winsup/cygwin/release/3.3.4
winsup/cygwin/select.cc
This page took 0.032965 seconds and 5 git commands to generate.