Skip to content

Commit

Permalink
handle EINTR return code from tcdrain to effectively block until flus…
Browse files Browse the repository at this point in the history
…h is complete
  • Loading branch information
ndusart committed Oct 23, 2024
1 parent f854b8d commit 0fdfc2e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/posix/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,13 @@ impl io::Write for TTYPort {
}

fn flush(&mut self) -> io::Result<()> {
nix::sys::termios::tcdrain(self.fd)
.map_err(|_| io::Error::new(io::ErrorKind::Other, "flush failed"))
loop {
return match nix::sys::termios::tcdrain(self.fd) {
Ok(_) => Ok(()),
Err(nix::errno::Errno::EINTR) => continue,
Err(_) => Err(io::Error::new(io::ErrorKind::Other, "flush failed")),
};
}
}
}

Expand Down

0 comments on commit 0fdfc2e

Please sign in to comment.