aboutsummaryrefslogtreecommitdiff
path: root/src/tty.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-09-24 16:11:50 -0700
committerJoe Wilm <joe@jwilm.com>2016-09-24 17:03:07 -0700
commitf1499d1d4518674c6c3c5c859a7028709bdd741d (patch)
tree4500d7a560b01d33b3da02e44c90ca7b0385158d /src/tty.rs
parentbe09467d48a5b7644411c2a09d948ee89509894e (diff)
downloadalacritty-f1499d1d4518674c6c3c5c859a7028709bdd741d.tar.gz
alacritty-f1499d1d4518674c6c3c5c859a7028709bdd741d.zip
Use evented I/O for the pty
This was largely an experiment to see whether writing and reading from a separate thread was causing terminal state corruption as described in https://github.com/jwilm/alacritty/issues/9. Although this doesn't seem to fix that particular issue. Keeping this because it generally seems more correct than reading/writing from separate locations.
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];