Skip to content

Commit

Permalink
async: Fix termios to be Sync
Browse files Browse the repository at this point in the history
Workaround until nix-rust/nix#1324 merges
  • Loading branch information
mkj committed Jun 16, 2024
1 parent 6b7542b commit 3d6a72c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions async/src/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ pub fn raw_pty() -> Result<RawPtyGuard, IoError> {
}

pub struct RawPtyGuard {
saved: Termios,
// nix Termios isn't Sync, pending https://github.com/nix-rust/nix/pull/1324
saved: libc::termios,
}

impl RawPtyGuard {
fn new() -> Result<Self, IoError> {
let saved = Self::set_raw()?;
let saved = Self::set_raw()?.into();

Ok(Self {
saved,
Expand Down Expand Up @@ -111,7 +112,7 @@ impl Drop for RawPtyGuard {
fn drop(&mut self) {
use nix::sys::termios::*;
let fd = std::io::stdin().as_raw_fd();
let r = tcsetattr(fd, SetArg::TCSADRAIN, &self.saved);
let r = tcsetattr(fd, SetArg::TCSADRAIN, &self.saved.into());
if let Err(e) = r {
warn!("Failed restoring TTY: {e}");
}
Expand Down

0 comments on commit 3d6a72c

Please sign in to comment.