summaryrefslogtreecommitdiff
path: root/src/pty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pty.rs')
-rw-r--r--src/pty.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pty.rs b/src/pty.rs
index ae304d83..bb266a65 100644
--- a/src/pty.rs
+++ b/src/pty.rs
@@ -95,6 +95,21 @@ impl io::Write for PtyMaster {
}
}
+impl io::Read for &PtyMaster {
+ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
+ unistd::read(self.0, buf).map_err(io::Error::from)
+ }
+}
+
+impl io::Write for &PtyMaster {
+ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+ unistd::write(self.0, buf).map_err(io::Error::from)
+ }
+ fn flush(&mut self) -> io::Result<()> {
+ Ok(())
+ }
+}
+
/// Grant access to a slave pseudoterminal (see
/// [`grantpt(3)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/grantpt.html))
///