mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 11:48:13 +01:00
Avoid hardcoding 5 for errno EIO
We could use libc::EIO to improve readability of the code.
This commit is contained in:
@@ -2,6 +2,7 @@ use crate::io::set_non_blocking;
|
|||||||
use crate::tty::{Tty, TtySize};
|
use crate::tty::{Tty, TtySize};
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use nix::errno::Errno;
|
use nix::errno::Errno;
|
||||||
|
use nix::libc::EIO;
|
||||||
use nix::sys::select::{select, FdSet};
|
use nix::sys::select::{select, FdSet};
|
||||||
use nix::sys::signal;
|
use nix::sys::signal;
|
||||||
use nix::sys::wait::{self, WaitPidFlag, WaitStatus};
|
use nix::sys::wait::{self, WaitPidFlag, WaitStatus};
|
||||||
@@ -301,7 +302,7 @@ fn read_non_blocking<R: Read + ?Sized>(
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
if e.kind() == ErrorKind::WouldBlock {
|
if e.kind() == ErrorKind::WouldBlock {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
} else if e.raw_os_error().is_some_and(|code| code == 5) {
|
} else if e.raw_os_error().is_some_and(|code| code == EIO) {
|
||||||
Ok(Some(0))
|
Ok(Some(0))
|
||||||
} else {
|
} else {
|
||||||
return Err(e);
|
return Err(e);
|
||||||
@@ -317,7 +318,7 @@ fn write_non_blocking<W: Write + ?Sized>(sink: &mut W, buf: &[u8]) -> io::Result
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
if e.kind() == ErrorKind::WouldBlock {
|
if e.kind() == ErrorKind::WouldBlock {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
} else if e.raw_os_error().is_some_and(|code| code == 5) {
|
} else if e.raw_os_error().is_some_and(|code| code == EIO) {
|
||||||
Ok(Some(0))
|
Ok(Some(0))
|
||||||
} else {
|
} else {
|
||||||
return Err(e);
|
return Err(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user