From 1c936ca06c623b6c56c1d332a7df82c1d7137c1a Mon Sep 17 00:00:00 2001 From: Michael Bradshaw Date: Wed, 12 Jun 2019 22:59:41 +0000 Subject: [PATCH] Use stdout to get and set terminal attributes --- src/sys/redox/attr.rs | 4 ++-- src/sys/unix/attr.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sys/redox/attr.rs b/src/sys/redox/attr.rs index c6489a5..0564895 100644 --- a/src/sys/redox/attr.rs +++ b/src/sys/redox/attr.rs @@ -5,7 +5,7 @@ use super::{cvt, syscall, Termios}; pub fn get_terminal_attr() -> io::Result { let mut termios = Termios::default(); - let fd = cvt(syscall::dup(0, b"termios"))?; + let fd = cvt(syscall::dup(1, b"termios"))?; let res = cvt(syscall::read(fd, &mut termios)); let _ = syscall::close(fd); @@ -17,7 +17,7 @@ pub fn get_terminal_attr() -> io::Result { } pub fn set_terminal_attr(termios: &Termios) -> io::Result<()> { - let fd = cvt(syscall::dup(0, b"termios"))?; + let fd = cvt(syscall::dup(1, b"termios"))?; let res = cvt(syscall::write(fd, termios)); let _ = syscall::close(fd); diff --git a/src/sys/unix/attr.rs b/src/sys/unix/attr.rs index 5e21fba..d25e942 100644 --- a/src/sys/unix/attr.rs +++ b/src/sys/unix/attr.rs @@ -9,7 +9,7 @@ pub fn get_terminal_attr() -> io::Result { } unsafe { let mut termios = mem::zeroed(); - cvt(tcgetattr(0, &mut termios))?; + cvt(tcgetattr(1, &mut termios))?; Ok(termios) } } @@ -18,7 +18,7 @@ pub fn set_terminal_attr(termios: &Termios) -> io::Result<()> { extern "C" { pub fn tcsetattr(fd: c_int, opt: c_int, termptr: *const Termios) -> c_int; } - cvt(unsafe { tcsetattr(0, 0, termios) }).and(Ok(())) + cvt(unsafe { tcsetattr(1, 0, termios) }).and(Ok(())) } pub fn raw_terminal_attr(termios: &mut Termios) {