[newlib-cygwin/cygwin-3_6-branch] Cygwin: select: Set errno when peek() returns -1
Takashi Yano via Cygwin-cvs <[email protected]> Sun, 19 Apr 2026 10:34:19 +0000 (GMT)
| Newsgroups | gmane.os.cygwin.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3De5c408f6e96= 48bff2258efb4e6b81dd2561a8faf commit e5c408f6e9648bff2258efb4e6b81dd2561a8faf Author: Takashi Yano <[email protected]> Date: Sat Apr 18 04:31:15 2026 +0900 Cygwin: select: Set errno when peek() returns -1 =20 Currently, poll() sometimes returns -1 with errno =3D=3D 0 if the fd is not opened. This is due to lack of setting errno when peek() fails. This patch ensure to set errno to thread_errno if peek() returns -1. =20 Addresses: https://cygwin.com/pipermail/cygwin/2026-April/259602.html Fixes: 8382778cdb57 ("Cygwin: console: fix select() behaviour") Reported-by: Nahor <[email protected]> Signed-off-by: Takashi Yano <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> (cherry picked from commit 6a588c29b562c6da08061f68d71733c78fbfefc3) Diff: --- winsup/cygwin/release/3.6.8 | 4 ++++ winsup/cygwin/select.cc | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/release/3.6.8 b/winsup/cygwin/release/3.6.8 index dc7103c67..5199ad86b 100644 --- a/winsup/cygwin/release/3.6.8 +++ b/winsup/cygwin/release/3.6.8 @@ -22,3 +22,7 @@ Fixes: Addresses: https://github.com/git-for-windows/git/issues/5632 =20 - Fix pty bugs regarding GDB with pty. + +- Add missing errno setting on error that poll() is called for closed + file descriptor. + Addresses: https://cygwin.com/pipermail/cygwin/2026-April/259602.html diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 8a94ac076..523c46ee6 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -561,7 +561,10 @@ select_stuff::poll (fd_set *readfds, fd_set *writefds,= fd_set *exceptfds) { int ret =3D s->peek ? s->peek (s, true) : 1; if (ret < 0) - return -1; + { + set_errno (s->thread_errno); + return -1; + } n +=3D (ret > 0) ? set_bits (s, readfds, writefds, exceptfds) : 0; } return n;