delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/09/03/22:28:49

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 5842SmNC4149829
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 5842SmNC4149829
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=aHlbY4SA
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7ECDA385840D
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1756952925;
bh=Az/b6vmCJ54+Jhi/X1cye2whLiyehbAflF60/kCRDmQ=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=aHlbY4SACVOvfcYuuMMp4SgmEPRYk8Puwklt3hLnz9p/vnUlyhyOjoCoEW0WzIWcv
tBr3ht6hBQjSlgGG1+nZLgvNsuZG/RX5d2+SzlizeuBWC/gr90lfjCPW0X+5arKY30
pegTl7+MLG87ayjhKCTED7Oi+RTR0KlviIvOkxWo=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F34A83858D26
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F34A83858D26
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1756952891; cv=none;
b=xNeKCWEZetk0pGCbsdTJH9w8mfNLRWETNs/CMmWqWqRD1X8riHPl5xGs1NoQcayyaoP8jm3eNvTsKZpJw+qguel2NiBgDCdw2mu5McIBbrXkz42mT52mZdPvN2FO8BPgyHmTVbV+GStdhEtEV5bGLN4O9YHXjT8GureUGGK3smA=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1756952891; c=relaxed/simple;
bh=yey/A/oBguxEWO+ZctYt/cPdnPDgtUpnNnepcsYfvg8=;
h=DKIM-Signature:From:To:Subject:Mime-Version:Date:Message-ID;
b=COebJoulhJ7ajrZ3bcKJJhVXB8V87tFWDZ+jg/TdpDxt0yt9pExUudLE0HdtLW+8STosH6c+9M2lGcyO/10mENZ3VWODqRkFRJIXPKDF/444K9PmhpEpdBa5+9yTfP/A605LuJqrZjaAgcD9OBNL+zZHBrdGWbFTkORM3o1S99k=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F34A83858D26
X-QQ-XMRINFO: NyFYKkN4Ny6FSmKK/uo/jdU=
X-QQ-XMAILINFO: NpBP8bGHrwA/xcfE1lazE2ZrEoleDz4WER7Gk6e6BaHK49X12JENEa+ARnIYuO
zML1HNHEuFP85x0t6PjBXrE9PYswiP0EYjvizi1y8uAVzPq6k/xSaAHISSIydrfiQszhmqY0oW0P6
n4movHYfwoRQ92nYhWTSsYNGN7TQdIF7ueeq2U+zkKlKozmfSmhA8Gya1RH0MGJKawvYAmuK00dE9
29vHxCKIOhP/2y1b4mfdH2TCfBGaCwrcjr+DCgotXYtTf7NABbZpy0mGC6LHWvR9HhMq36JB0NiQG
ErH/tDs02VEEvyMgsIZxPKt8GfuC5PW9EBMRNnZUnI/AG3FkpUgA1Pq5NnMSNmIOq92ZWxjdbLLH/
vY0xg437ZlffetINdrb1dJdPnaw1CcPQv5rOlRH5/dmFDrYcdkqdBWG3nFEFBGbI7wOfGrZxFOI+k
cpOE8X20foIL69L+mGhu2QNBu5NCYru3NUZr8Yq4MvkgdDkL0fQPx5HSnB9ctHqlo4Ym77Hbsf5Sr
jS0f2K9cxLq6/arzRMHKZh+PVg8UW6VXExqSuzcFXsIU9cb1DR8waOyFfysd4G3j5Hp11+631paLy
iS2qlcwHQHmo3OF8ofKD3Pw+sDBEUn2c9wUTqlpZRxlZcLUj8WONfzxQgclX4w0UIFYyhVLtvDC3D
aEx4jnaJEYK9x93jYNR7hygUJoAkWebCuClPHuqaVri0PyrAJu8ej8KzBVzkXunpLSwRdrisd5gp9
CXti5r7ccFjwLf9nHFW0AEoCGvEHq+y+rpqRitFSIg6z47utw5Z3Jiht38iGjBhqdfv+0HA16fx9u
Dn2t9lhAPMeR+jClIynhucdnT4W6Wrr9xCQgP4zvtCVQOFdmFannjvSmbtBMuOFfy4OcJyxgIKOG0
xiqJ6+WXbypus0lpFPj0Rn9zg+Vj5K5rzNcMpeVQvxZVUNTEy9XksknmaR9HFfJH88CKzAOggVdwd
aLch73BmmutICI0aoklXRFfDqRjTnIIaR0F4qRJhqmiXSQp9C+UC0aj1CNhfgOuKqOahy5q26SXl4
NMtsaoadIjLWgJjjeLpXAZ00ElQ==
To: "=?utf-8?B?Y3lnd2lu?=" <cygwin AT cygwin DOT com>
Subject: Cygwin select() returns -1 with errno 0
Mime-Version: 1.0
Date: Thu, 4 Sep 2025 10:28:05 +0800
X-Priority: 3
Message-ID: <tencent_816228BD23D3D2111B35AA9FF0D80C4AD706@qq.com>
X-QQ-MIME: TCMime 1.0 by Tencent
X-Mailer: QQMail 2.x
X-QQ-Mailer: QQMail 2.x
X-QQ-mid: xmseza23-0t1756952885tc48im62l
X-Content-Filtered-By: Mailman/MimeDel 2.1.30
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: a2uria via Cygwin <cygwin AT cygwin DOT com>
Reply-To: =?utf-8?B?YTJ1cmlh?= <a2uria AT qq DOT com>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

The problem is that `select` returns -1 with errno 0, so `perror` says `select: No error`.

Copied from https://github.com/msys2/msys2-runtime/issues/308&nbsp;as previously website of cygwin is temporary unavailable for me.


Original seen in https://github.com/fish-shell/fish-shell/pull/11238/commits/0ad62cea2a9a6606128b182d11b3aac4a62b3b9d in https://github.com/fish-shell/fish-shell/pull/11238


It occurs randomly.


![](https://github.com/user-attachments/assets/6e149de7-ca87-4b30-bac7-fb690c153da9)


```
$ fish -c 'ls &gt; /dev/null'
select: No error
```


However when using `strace` this occurs more often. The following example uses `strace -f -m syscall,select ./fish -c 'sha256sum fish.exe' &amp;&gt; output.txt`.


<details&gt;


<summary&gt;Trimmed output</summary&gt;


```
&nbsp; 627 &nbsp;479850 [fish] fish 1628 pselect: pselect (15, 0x7FFD0C690, 0x7FFD0C680, 0x7FFD0C670, 0x0, 0x0)
&nbsp; 104 &nbsp;479954 [fish] fish 1628 pselect: to NULL, us -1
&nbsp; 770 &nbsp;480724 [fish] fish 1628 select: sel.always_ready 0
&nbsp;3427 &nbsp;484151 [main] fish 1628 write: write(15, 0x7FFFF9E4C, 1)
&nbsp; &nbsp;89 &nbsp;484240 [main] fish 1628 write: 1 = write(15, 0x7FFFF9E4C, 1)
&nbsp; &nbsp;53 &nbsp;484293 [pipesel] fish 1628 peek_pipe: read: pipe:[12884907236], ready for read: avail 1
&nbsp; 108 &nbsp;484401 [fish] fish 1628 select_stuff::wait: wait_ret 2, m = 3. &nbsp;verifying
&nbsp; 101 &nbsp;484502 [fish] fish 1628 set_bits: me 0xA00046280, testing fd 14 (pipe:[12884907236])
&nbsp; &nbsp;57 &nbsp;484559 [main] fish 1628 read: read(12, 0x7FFFF5DF8, 16384) nonblocking
&nbsp; 155 &nbsp;484714 [fish] fish 1628 set_bits: ready 1
&nbsp; 114 &nbsp;484828 [fish] fish 1628 set_bits: me 0xA00045C20, testing fd 12 (pipe:[8589939940])
&nbsp; 117 &nbsp;484945 [fish] fish 1628 set_bits: ready 0
&nbsp; &nbsp;52 &nbsp;484997 [main] fish 1628 read: -1 = read(12, 0x7FFFF5DF8, -1), errno 11
&nbsp; &nbsp;53 &nbsp;485050 [fish] fish 1628 select_stuff::wait: res after verify 0
&nbsp; 102 &nbsp;485152 [fish] fish 1628 select_stuff::wait: returning 0
&nbsp; &nbsp;51 &nbsp;485203 [main] fish 1628 close: close(12)
&nbsp; &nbsp;52 &nbsp;485255 [fish] fish 1628 select: sel.wait returns 0
&nbsp; 100 &nbsp;485355 [main] fish 1628 fhandler_base::close: closing 'pipe:[8589939940]' handle 0x2F0
&nbsp; &nbsp;49 &nbsp;485404 [main] fish 1628 close: 0 = close(12)
&nbsp; &nbsp;45 &nbsp;485449 [fish] fish 1628 peek_pipe: pipe:[12884907236], already ready for read
&nbsp; &nbsp;52 &nbsp;485501 [main] fish 1628 close: close(13)
&nbsp; &nbsp;51 &nbsp;485552 [fish] fish 1628 set_bits: me 0xA00046280, testing fd 14 (pipe:[12884907236])
&nbsp; 108 &nbsp;485660 [fish] fish 1628 set_bits: ready 1
&nbsp; &nbsp;56 &nbsp;485716 [main] fish 1628 fhandler_base::close: closing 'pipe:[8589939940]' handle 0x2D8
&nbsp; &nbsp;53 &nbsp;485769 [main] fish 1628 close: 0 = close(13)
&nbsp; &nbsp;45 &nbsp;485814 [fish] fish 1628 select_stuff::cleanup: calling cleanup routines
&nbsp; 293 &nbsp;486107 [fish] fish 1628 select_stuff::destroy: deleting select records
&nbsp; 310 &nbsp;486417 [fish] fish 1628 select_stuff::cleanup: calling cleanup routines
&nbsp; 101 &nbsp;486518 [fish] fish 1628 select_stuff::destroy: deleting select records
&nbsp; 107 &nbsp;486625 [fish] fish 1628 pselect: -1 = select (15, 0x7FFD0C690, 0x7FFD0C680, 0x7FFD0C670, 0x0), errno 0
select &nbsp;890 &nbsp;487515 [fish] fish 1628 write: 6 = write(2, 0x100C27640, 6)
: &nbsp; 208 &nbsp;487723 [fish] fish 1628 write: 2 = write(2, 0x100C5BA30, 2)
No error &nbsp;206 &nbsp;487929 [fish] fish 1628 write: 8 = write(2, 0x2102D4D35, 8)


&nbsp; 197 &nbsp;488126 [fish] fish 1628 write: 1 = write(2, 0x100C5C791, 1)
```


</details&gt;


The binary can be compiled using following commands with MSYS2.


```
pacman -S gcc mingw-w64-x86_64-rustup
rustup component add rust-src --toolchain nightly-x86_64-pc-windows-gnu
cargo +nightly-x86_64-pc-windows-gnu install -Z build-std --target x86_64-pc-cygwin --profile release-with-debug --git https://github.com/fish-shell/fish-shell.git --rev d8e5821 --bin fish
```


Note that [`--rev d8e5821`](https://github.com/fish-shell/fish-shell/commit/d8e5821a3b8f944cb071b98781680f15ba4effd6) is required as workaround is added in https://github.com/fish-shell/fish-shell/commit/4508b5b0db7b012ae2c19f4f7aa9df74ac89ea3c. Commit history is available [here](https://github.com/fish-shell/fish-shell/commits/4508b5b0db7b012ae2c19f4f7aa9df74ac89ea3c/).


Code that trigger `perror` is here.


https://github.com/fish-shell/fish-shell/blob/d8e5821a3b8f944cb071b98781680f15ba4effd6/src/fd_monitor.rs#L390-L395


```rust
let ret = fds.check_readable(timeout.map(Timeout::Duration).unwrap_or(Timeout::Forever));
if ret < 0 &amp;&amp; !matches!(errno().0, libc::EINTR | libc::EBADF) {
&nbsp; &nbsp; // Surprising error
&nbsp; &nbsp; perror("select");
}
```

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019