Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
doy committed Aug 6, 2023
1 parent 7a73249 commit 847bcb2
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,19 @@ impl Pty {
}

pub fn set_term_size(&self, size: crate::Size) -> crate::Result<()> {
let size: libc::winsize = size.into();
let size = libc::winsize::from(size);
let fd = self.0.as_raw_fd();
// TODO: upstream this to rustix
unsafe {
let ret = libc::ioctl(
fd,
libc::TIOCSWINSZ,
std::ptr::NonNull::from(&size).as_ptr(),
);
if ret == -1 {
Err(rustix::io::Errno::from_raw_os_error(
std::io::Error::last_os_error()
.raw_os_error()
.unwrap_or(0),
)
.into())
} else {
Ok(())
}
let ret = unsafe {
libc::ioctl(fd, libc::TIOCSWINSZ, std::ptr::addr_of!(size))
};
if ret == -1 {
Err(rustix::io::Errno::from_raw_os_error(
std::io::Error::last_os_error().raw_os_error().unwrap_or(0),
)
.into())
} else {
Ok(())
}
}

Expand Down

0 comments on commit 847bcb2

Please sign in to comment.