diff options
author | Joe Wilm <joe@jwilm.com> | 2016-09-24 16:11:50 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-09-24 17:03:07 -0700 |
commit | f1499d1d4518674c6c3c5c859a7028709bdd741d (patch) | |
tree | 4500d7a560b01d33b3da02e44c90ca7b0385158d /src/tty.rs | |
parent | be09467d48a5b7644411c2a09d948ee89509894e (diff) | |
download | alacritty-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.rs | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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]; |