Debian Codegraph @

src/exec/io_util.rs

raw symbols SCIP
1 use std::io;
2
3 /// Return `true` if the IO error is an interruption.
4 pub(super) fn was_interrupted(err: &io::Error) -> bool {
5 // ogsudo checks against `EINTR` and `EAGAIN`.
6 matches!(
7 err.kind(),
8 io::ErrorKind::Interrupted | io::ErrorKind::WouldBlock
9 )
10 }
11
12 /// Call `f` repeatedly until it succeeds or it encounters a non-interruption error.
13 pub(super) fn retry_while_interrupted<T>(mut f: impl FnMut() -> io::Result<T>) -> io::Result<T> {
14 loop {
15 match f() {
16 Err(err) if was_interrupted(&err) => {}
17 result => return result,
18 }
19 }
20 }