diff --git a/src/terminal/sys/unix.rs b/src/terminal/sys/unix.rs index 9e50e53..13b56bd 100644 --- a/src/terminal/sys/unix.rs +++ b/src/terminal/sys/unix.rs @@ -32,8 +32,9 @@ pub(crate) fn size() -> Result<(u16, u16)> { ws_ypixel: 0, }; - let fd = if let Ok(file) = File::open("/dev/tty") { - FileDesc::new(file.into_raw_fd(), true).raw_fd() + let file = File::open("/dev/tty").map(|file| (FileDesc::new(file.into_raw_fd(), true))); + let fd = if let Ok(file) = &file { + file.raw_fd() } else { // Fallback to libc::STDOUT_FILENO if /dev/tty is missing STDOUT_FILENO