fix(unix): retry EINTR in poll/select/read#286
fix(unix): retry EINTR in poll/select/read#286jh-block wants to merge 2 commits intoconsole-rs:mainfrom
Conversation
e629345 to
0f4804e
Compare
0f4804e to
02dec12
Compare
|
Thanks for the clippy fix -- can you split it out in a separate commit please? For the first hunk's loop, I think we could do |
d4bbaab to
efd7139
Compare
Fixes console-rs#212. read_single_key treats any Err(Interrupted) from read_single_key_impl as Ctrl-C and forwards it via libc::raise(SIGINT). That's correct only for the synthesized Err(Interrupted) read_bytes returns when it sees a \x03 byte. EINTR returned by poll/select/read because of an unrelated signal (SIGCHLD, SIGWINCH, etc.) takes the same path and incorrectly kills the program with SIGINT. Retry EINTR inside the syscall wrappers so Err(Interrupted) reaching read_single_key unambiguously means a \x03 byte was read.
Silences clippy::collapsible_match warning on clippy 1.95+.
efd7139 to
e08b569
Compare
|
This does not seem like a clean split. Also, the first commit looks like it makes some unrelated/unnecessary changes. If you are using an LLM to help with this, please self-review before asking for my review. |
|
Can you clarify what you mean? The only perhaps-unrelated change in the first commit is reducing the scope of the unsafe block in |
|
@djc is there any chance you could take another look at the two commits? I am not sure how to interpret your earlier comment; the split of the clippy fix and the logic fix into two commits is clean, and the first commit (the EINTR logic fix) contains only the changes I intended to make. If you would like something changed can you indicate what it is? |
| if err.kind() == io::ErrorKind::Interrupted { | ||
| continue; | ||
| } | ||
| break Err(err); |
There was a problem hiding this comment.
Nit: suggest writing this as
match err.kind() {
io::ErrorKind::Interrupted => continue,
_ => break Err(err),
}| if err.kind() == io::ErrorKind::Interrupted { | ||
| continue; | ||
| } | ||
| break Err(err); |

Fixes #212.
read_single_keytreats anyErr(Interrupted)fromread_single_key_implas Ctrl-C and forwards it vialibc::raise(SIGINT). That's correct only for the synthesizedErr(Interrupted)read_bytesreturns when it sees a\x03byte. EINTR returned bypoll/select/readbecause of an unrelated signal (SIGCHLD, SIGWINCH, etc.) takes the same path and incorrectly kills the program with SIGINT.Retry EINTR inside the syscall wrappers so
Err(Interrupted)reachingread_single_keyunambiguously means a\x03byte was read.