aboutsummaryrefslogtreecommitdiff
path: root/src/tty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tty.rs')
-rw-r--r--src/tty.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tty.rs b/src/tty.rs
index accf0226..988db37e 100644
--- a/src/tty.rs
+++ b/src/tty.rs
@@ -274,6 +274,12 @@ pub fn new(rows: u8, cols: u8) -> Tty {
libc::close(slave);
}
+ unsafe {
+ // Maybe this should be done outside of this function so nonblocking
+ // isn't forced upon consumers. Although maybe it should be?
+ set_nonblocking(master);
+ }
+
Tty { fd: master }
}
}
@@ -320,6 +326,13 @@ impl Tty {
}
}
+unsafe fn set_nonblocking(fd: c_int) {
+ use libc::{fcntl, F_SETFL, F_GETFL, O_NONBLOCK};
+
+ let res = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
+ assert_eq!(res, 0);
+}
+
#[test]
fn test_get_pw_entry() {
let mut buf: [i8; 1024] = [0; 1024];